mirror of
https://github.com/imputnet/cobalt.git
synced 2026-05-24 05:00:50 -05:00
Add option for setting more recognizable file names #86
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @06000208 on GitHub (Jul 4, 2023).
When I save files, I would prefer the file name to contain relevant information that could be later used to determine the source of the file.
For example, the media from this tweet https://twitter.com/dril/status/1667377869566390280 being saved as
dril-1667377869566390280.png, with the syntaxhandle-id.extSince cobalt handles multiple platforms, I wouldn't mind the name of the platform being included, if that's a necessity.
This feature request was inspired by how tw-media-downloader (extension, repo) handles file names, as it recently stopped working with direct tweet downloads.
Proposed Technical Implementation
In a perfect world, you would be able to use the download attribute on an anchor tag with the same URL that cobalt normally opens, but that's impossible as the download attribute only works with same-origin URLs and blob downloads.
Thusly, in order to achieve this client side, cobalt's javascript would have to:
I'm unsure if there's anything platforms could do to prevent files from being retrieved client side this way, probably something to do with CORS, but I of course hope this method would consistently work.
Otherwise, this could be achieved server side by proxying the files with the desired Content-Disposition header, but I expect doing it that way would, in my opinion:
@wukko commented on GitHub (Jul 21, 2023):
cobalt already puts post id into file names for all services, but all extra info is not added at this time.
@06000208 commented on GitHub (Jul 23, 2023):
this doesn't appear to be the case? for example, take this tweet: https://twitter.com/KS_wktk/status/1370702788624142336
to download the video, cobalt opens this in a new tab or copies it to clipboard, neither of which provide control over file name: https://video.twimg.com/tweet_video/EwW2ovRUcAYOHfC.mp4
when saved with ctrl+s, it will have the default file name of EwW2ovRUcAYOHfC.mp4 and won't contain the post id 1370702788624142336
@wukko commented on GitHub (Jul 23, 2023):
that’s because it’s a direct file link straight from twitter. cobalt can change the filename only when it handles files by itself.
@06000208 commented on GitHub (Jul 24, 2023):
yes, that was clear, just asking for clarification with an example, as you stated it already puts post id into file names for all services, and if that's true, I wouldn't have needed to make the feature request
@wukko commented on GitHub (Oct 15, 2023):
added in 7.6