nondanee / weiboPicDownloader

Download weibo images without logging-in
GNU General Public License v3.0
268 stars 63 forks source link

Can we save images with Date? #39

Closed mirusu400 closed 5 years ago

mirusu400 commented 5 years ago

Hello. I know that this program only downloads weibo picture files with native raw file name, but I want to save the name with date(Ex. 20190606_6b084396gw1f8ta9obw9gj20rsbnve84.jpg) Is this possible? Thanks.

nondanee commented 5 years ago

It is possible but need extra work

The API response a formatted time like "2 mins ago", "yesterday", "6-10", "2018-12-26" instead of an accurate post time

So a parser is needed, and only date can be extracted without post time I will add it as soon as possible

nondanee commented 5 years ago

I added the date information with key 'date' to the format item just now Please replace the default logic with a new naming rule whatever you want to have

https://github.com/nondanee/weiboPicDownloader/blob/f9dd7dd6aaa3babcd25a14cf1f805d7ec33dfe03/weiboPicDownloader.py#L227-L231

For your example format (Ex. 20190606_6b084396gw1f8ta9obw9gj20rsbnve84.jpg), the following should work

-- return name
++ return item['date'].strftime('%Y%m%d') + '_' + name
afterdelight commented 5 years ago

Should be better to add as an command option on the script instead of manually modifiy the script, I'm sure a lot of people wanna use this feature :)

nondanee commented 5 years ago

Use -n option with argument '{date:%Y%m%d}_{name}'

afterdelight commented 5 years ago

You should put the info in front of the page. People will just put ' -n date '.