gyng / save-in

WebExtension for saving media, links, or selections into user-defined directories
MIT License
199 stars 25 forks source link

Twitter renaming #210

Open TheBracer opened 5 months ago

TheBracer commented 5 months ago

I have a question regarding saving images -> renaming them from Twitter, is it possible to include the twitter handle and/or username before the filename? Like it would come out as "twitter_Username1(@username1)_Hf98h89hsad.jpg"?

rudolphos commented 5 months ago

You must use the Dynamic Downloads (Advanced) feature.

If you save an image from someone's profile page or direct tweet url, the variables you get are: image

The only one containing username is :pageurl:.

You could use this:

//X & twitter
pageurl: twitter.com/(.*)
into: :pageurl:_:filename:.*

//X & twitter
pageurl: x.com/(.*)
into: :pageurl:_:filename:.*

Saving an image from a profile page or direct tweet page, would result in a filename:

https___twitter.com_elonmusk_status_1750368096945070474_GEqOgS2WkAAQiSz.jpg or https___twitter.com_elonmusk_GEqOgS2WkAAQiSz.jpg

It would include the entire pageurl though, but there would at least be username saved. You can use something like Bulk Rename Utility to clean up https___twitter.com_ once in a while to avoid filename length conflicts.

You could also use regex and capture groups in this extension to remove everything before /username/, but it would take more time.

TheBracer commented 5 months ago

I see, that's good enough for me thanks!