gyng / save-in

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

Image file extensions not recognized #135

Open neuralstamp opened 4 years ago

neuralstamp commented 4 years ago

Image extensions not recognized in 'Rename and Route Downloads' section. This particular site has urls to image files which end in '/' or 'full' e.g. 'https://www.blacktowhite.net/media/19113679_10155212144278382_2002531145581403089_n-jpg.317672/'

and via 'view image'

e.g. 'https://www.blacktowhite.net/media/19113679_10155212144278382_2002531145581403089_n-jpg.317672/full'

I have been using these rules below to rename the files, however if I try to use :filename:, :fileext: or :naivefileext: in the code, the file is downloaded as a blank file because it has no extension assigned to it. This is because the code only recognizes 'full' (or occasionally '_') as the extension. 'full' is found at the end portion of the url in 'view image'.

filename: (.*)
into: :year:-:month:-:day:-:hour:-:minute:-:second:.:filename:

filename: .*
into: :year:-:month:-:day:-:hour:-:minute:-:second:.:filename:

filename: (.*)(\full|_)
sourceurl: www.blacktowhite.net
capture: filename
into: :year:-:month:-:day:-:minute:.:hour:.:second:.:filename:

I can easily download and rename image files from other sites, but the add-on does not recognize image file extensions in the code from this particular website, only 'full' and '_' in the 'view image' url.

What am I doing wrong?

I am using Firefox 71.0 64-bit

Tynach commented 4 years ago

In general, it seems as if it only uses the URL to determine a filename, as if filename and fileext are the same as naivefilename and naivefileext, respectively. Also, at least for image files, the mediatype matcher never seems to be filled in at all.

Firefox 75.0 64-bit on Ubuntu Linux 18.04 LTS (technically I use KDE Neon, but the Firefox binaries come from Ubuntu's repositories).

gyng commented 4 years ago

Yes, from a really quick look at this I believe this is blocked on onDeterminingFilename. WebExtensions in FF don't have the same access as the browser does to the filename.