Spark-NF / twitter_media_downloader

Twitter media downloader.
Apache License 2.0
293 stars 52 forks source link

Including date in output file name not working correctly #28

Closed LorenzoAlemanHub closed 2 years ago

LorenzoAlemanHub commented 2 years ago

Hello, great program you got here! Used it a couple months ago on windows to download all the media from a user's likes and it worked perfectly. Tried again today but ran into an issue with the date in the file name. Command I used was python twitter_media_downloader.py -o out -f "[%date%] %filename%.%ext%" -s large -u <username> --since 2021-11-01 -l and I ended up with the files in a directory ...\twitterMediaDownloaderRepo\twitter_media_downloader\out\[11\06\<file>. I think there is an issue with the date formatting, it's formatting to MM/DD/YYYY when it used to be MM-DD-YYYY and I think the / is causing it to create directory when writing the file.

Spark-NF commented 2 years ago

Are you in Windows and using cmd/powershell?

It's possible that your shell is replacing %date% by the environment variable DATE, which contains the current date in your locale's format.

Make sure the % is escaped properly in that case. It might be hard in CMD, but you can do something like:

python twitter_media_downloader.py -o out -f "test %date% %filename%.%ext%" -u Twitter

Becomes (note the quotes around the percent):

python twitter_media_downloader.py -o out -f "test "%"date"%" %filename%.%ext%" -u Twitter
LorenzoAlemanHub commented 2 years ago

(note the quotes around the percent) That did it, thanks!