Skip to content

Conversation

@JoshMHardy
Copy link

Guidance on using cookie string. Without quote marks, the spaces and semi-colons in the cookie string are interpreted by the shell.

Guidance on using cookie string. Without quote marks, the spaces and semi-colons in the cookie string are interpreted by the shell.
@patrickkfkan
Copy link
Owner

Hi, thanks for the PR. I note that you put "Cookie: patreon_device_id:..." as example. However, the "Cookie: " part is the request header name and not part of the cookie value itself. I have not come across a cookie that includes spaces, so I'm not sure if it is in fact necessary to enclose it in quotes. Would you be able to verify this?

@JoshMHardy
Copy link
Author

Hi,

Thanks for the reply!

I followed your instructions to copy the cookie in Firefox and the "Cookie:" was copied with it. Here is how it looked when copied to the clipboard (I've replaced the strings with zeroes to anonymise my cookie):

Cookie: patreon_locale_code=en-US; patreon_location_country_code=AU; patreon_device_id=00000000000000000000000; __cf_bm=0000000000000000000000; analytics_session_id=00000000000000000000; __ssid=0000000000000000; session_id=000000000000000; patreon_locale_code=en-US

The issue I had is with BASH interpreting the spaces as separate strings. The cookie input becomes just the first string "Cookie:" and the second string is interpreted as the URL e.g. "patreon_locale_code=en-US"

josh@ubuntu:~/$ patreon-dl --cookie Cookie: patreon_locale_code=en-US; patreon_location_country_code=AU; patreon_device_id=00000000000000000000000; __cf_bm=0000000000000000000000; analytics_session_id=00000000000000000000; __ssid=0000000000000000; session_id=000000000000000; patreon_locale_code=en-US https://www.patreon.com/posts/65221988

patreon-dl v2.3.0 Patreon Downloader

Error processing options:  Invalid URL: patreon_locale_code=en-US
 See usage with '-h' option.
--config-file: command not found

However, when I use quotes (either single or double quotes), the entire cookie is parsed and it works as expected:

josh@ubuntu:~/$ patreon-dl --cookie "Cookie: patreon_locale_code=en-US; patreon_location_country_code=AU; patreon_device_id=00000000000000000000000;
 __cf_bm=0000000000000000000000; analytics_session_id=00000000000000000000; __ssid=0000000000000000; session_id=000000000000000; patreon_locale_code=en-US" https
://www.patreon.com/posts/65221988

patreon-dl v2.3.0 Patreon Downloader

Jan 22 19:26:41: info: Created PostDownloader instance with config: : {
  type: 'post',
  targetURL: 'https://www.patreon.com/posts/65221988',
  postFetch: { type: 'single', postId: '65221988' },
  outDir: '/home/josh/',
  useStatusCache: true,
  dirNameFormat: {
    campaign: '{creator.vanity}[ - ]?{campaign.name}',
    content: '{content.id}[ - ]?{content.name}'
  },
  filenameFormat: { media: '{media.filename}' },
  include: {
    lockedContent: true,
    postsWithMediaType: 'any',
    postsInTier: 'any',
    campaignInfo: true,
    contentInfo: true,
    previewMedia: true,
    contentMedia: true,
    allMediaVariants: false,
    comments: false
  },
  request: { maxRetries: 3, maxConcurrent: 10, minTime: 333 },
  fileExistsAction: { content: 'skip', info: 'saveAsCopyIfNewer', infoAPI: 'overwrite' },
  dryRun: false
}

Proceed (Y/n)?

@patrickkfkan
Copy link
Owner

Right, I can see the spaces now within the cookie value.

What browser are you using to obtain the cookie? In my case, I'm using Firefox and simply right-clicking on the "Cookie" header and selecting "Copy Value" will omit the "Cookie: " part. Did you by any chance highlight the entire header (dragging across or triple-clicking it) before selecting "Copy Value"?

I think, to avoid ambiguity, we should just state "<cookie>" instead of "Cookie: patreon_device_id:...". Just in case users like me who didn't get the "Cookie: " part in the value will not have to wonder why that's the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants