EltonChou / TwitterMediaHarvest

Download twitter media with only one-click.
https://chrome.google.com/webstore/detail/media-harvest-twitter-med/hpcgabhdlnapolkkjpejieegfpehfdok
MIT License
434 stars 36 forks source link

[FEATURE] More customization in Filename Pattern #74

Open x-wiz opened 1 year ago

x-wiz commented 1 year ago

Describe the solution you'd like More customization in Filename Pattern, Like a textbox I can type the layout of the text, the order and also more info.

Example post: https://twitter.com/saltastic_/status/1658472020735303690

Example Filename pattern: twitter_{user-name}(@{user-id})_{date-time}_{status-id}_{file-type}

output: twitter_shio(@saltastic_)_20230516-135837_1658472020735303690_photo.jpg

EltonChou commented 1 year ago

Good suggestion.

I attempted to implement this feature in the past. But there are more works to do than I thought.

  1. Not every character can be used in the filename, this problem was related to how the file system works. And the most of users don't have this knowledge.
  2. Any filename should be considered as an unique filename. To prevent the users overwrite the file accidentally, the parser need to check the pattern is unique enough or not.
  3. Try to make file can be sorted well in filesystem,
  4. Try to make the filename is human-readable. Some infos are not necessary in filename like timestamp or file-type.
    • There are only two file-types in twitter media, image and video. And you can distinguish file type from their extension.
    • The most of file system can record the time when was the file created.
  5. user-name can be changed and it is not unique. user-id isunique, but it can be changed.

If you want to make a PR. There are few things need to be done.

  1. An advanced user toggle option.
  2. Defined the allowed pattern token.
  3. Input parser.
  4. When users are typing, need a UI component to give feedback.

Feel free to let me know if you need further information.

Doofy420 commented 1 year ago

Something like elonmusk 1673852066572406784_1-4 would be great too, which would make the resulting filenames compatible with a popular twitter ripper (gallery-dl)

EltonChou commented 1 year ago

Something like elonmusk 1673852066572406784_1-4 would be great too, which would make the resulting filenames compatible with a popular twitter ripper (gallery-dl)

@outlaw420 That's another serial pattern could be considered to implement.

In my opinion, I prefer non-space filename especially in CLI environment. but if you choose _ as seperator it would be confused in some situations, because _ is valid character in twitter id.

Doofy420 commented 1 year ago

I'm no dev but I understand it may cause a conflict in some environments, though it's great for casuals like me. It's up to you but it would be nice to have this option regardless. Thanks!

fredinno commented 10 months ago

I'm trying to go from TwMediaDownloader to this extension. The name format seems to work fine, except for the name format at the very end.

It would be nice if we could add a filename option to the end, and customize if there is the extra 0 at the end of the serial to make it fully compatible with the old extension. eg: {userName}-{serial}-{datetime}-img1.jpg (or vid for videos.)

Currently, I have to manually rename those files.

EltonChou commented 10 months ago

.jpg and .png are image. .mp4 is video, I don't think we need one more token to distinguish the file type.

cyanlamp247 commented 10 months ago

Regarding your comment on July 3, you can take a look at an extension called Powerful Pixiv Downloader. It can customize naming rules and enter characters that are not available in file names, but it will turn these characters into full-width characters. As for unique file names, it should be strict enough to maintain the existing rules that say "The pattern must include Tweet ID + Serial or Hash."

But it can be a lot of work. In terms of my personal needs, I currently only need to add a customizable prefix, such as "MH▲-", so that I can distinguish which files are downloaded through your extension.

fredinno commented 10 months ago

.jpg and .png are image. .mp4 is video, I don't think we need one more token to distinguish the file type.

I can use a mass renamer to fix the incompatibility, but it's another step that it would be nice if I could avoid if possible in case I forget.

EltonChou commented 10 months ago

Regarding your comment on July 3, you can take a look at an extension called Powerful Pixiv Downloader. It can customize naming rules and enter characters that are not available in file names, but it will turn these characters into full-width characters. As for unique file names, it should be strict enough to maintain the existing rules that say "The pattern must include Tweet ID + Serial or Hash."

But it can be a lot of work. In terms of my personal needs, I currently only need to add a customizable prefix, such as "MH▲-", so that I can distinguish which files are downloaded through your extension.

You can use Create sub-directory in options page.

EltonChou commented 10 months ago

.jpg and .png are image. .mp4 is video, I don't think we need one more token to distinguish the file type.

I can use a mass renamer to fix the incompatibility, but it's another step that it would be nice if I could avoid if possible in case I forget.

If you really need this you can make a PR.