Closed Cyranos closed 2 years ago
What do you mean with downloading pictures exactly? There's already a button for downloading pictures/videos in the browser itself right?
Yes, apologies I should've been more clear, I am wanting to be able to right click a picture, have it download and auto renamed to how many files there are in the chosen download location, e.g. if I download a photo too a folder where there is 2 other files already, then the file would be end up being named 3.png. Hopefully that makes sense? Again apologies for not being clear
Ah that makes sense. Unfortunately I don't think that's possible. You can download files using this extension by using the chrome.downloads
API through the crmAPI.browser
. Or even easier (but with less options) by using the crmAPI.GM_download
API. However, you can't read a directory and see what files are already in there because the browser doesn't allow file system reading.
Ahh okay, am I able too pass on the image to an external program?
@Cyranos I will provide you my code (WIP) that is 90% done and does just that by default. Renames duplicates (1) (2) etc...
It uses registry hard links to launch software on your PC from the browser. That's not actually what they're called. But it's like how you can click on something in steam store in your browser and it will open and navigate steam.exe to the relevant destination. Or a zoom link opens the room inside zoom desktop software from an email for example.
And then it runs MY software with launch options encoded via ";" semicolons. And passes the image links with cookies and referrer URL to download them via good old fashioned "CURL"
If you'd like this let me know. (I'm not sure if @SanderRonde will appreciate me putting code in this thread though)
@lilgandhi1199 Sounds great, you can go ahead and post it if you want :)
I'd be interested yea, been trying to solve this for a while now myself
Okay. My software is written in https://www.autohotkey.com/. You'll have to install that to be able to compile it to an exe yourself.
[1] Edit with notepad or Notepad++ the "media.ahk" file You'll edit the 10th line by removing the two semicolons and fill in your download location. ;;Default = C:\Users\Mike\Downloads ^^^ Then if you installed autohotkey with default options you should see the entry "Compile script" when you right click this .ahk
Now place it in whatever directory you want. I place my compiled scripts inside my user folder C:\Users\Mike and I would advise the same to keep it simple in the next step.
[2] Now edit media.reg file which is responsible for placing the hard link into your system (so when the browser requests it it knows what to redirect all output into the EXE. Note the formatting here is very important....... Replace Mike with your username....which in windows 10 is usually strange so actually check it!
[3] Finally copy all the contents of media.txt (Ctrl+A), which is the custom right click menu javascript code, and paste it into the extension "Add Script" and you're done.
With newer versions of chrome they prompt you on fresh websites to checkmark approval to launch an external program. But usually it only happens once the first time you use the extension on THAT website.
MEDIA 1-22-22.zip / / / / / Let me know how it goes. It's tricky to even grab the images correctly everytime. Maybe @SanderRonde can actually improve that basic part of the code!
Inside media.txt is the javascript and "currentElement" is the image URL if you can lend any helping hands as you were stating about chrome.Downloads???
Spread the love. Have fun guys
Looks good, might need a bit of tuning to make it work for this specific situation (not sure if the auto-number-incrementing stuff is already built in) but other than that it should probably do the job.
It's the minimum behavior of my script yes. It does everything he is looking for already. But websites don't always encode the image URLs the same. That's why it's 90% done. It works on 90% of all websites downloading images that you right click on. And I built in other renaming like on twitter if it can see it'll grab the user's @ handle and prename the image with that. etc
Been doing some messing about, and I have not been able to properly set the name of the created file, are you possibly able to help @lilgandhi1199 ? Of course the moment I post this I figure it out, apologies
@Cyranos First off it uses the default name of the file as stated on the server. Has it been functioning plain and simple so far to download images and auto-rename them?
So far, yep! Just having to learn AutoHotkey as I have never messed with it before
Awesome! I'm happy for you my friend. This has improved many speed things for me personally mainly because it doesn't take the time to ask for the filename and save location.
What do you expect to happen? A prompt inside your browser for the name similar to when you hit save image? But it could fill in what it expects to be named and let you edit it before hitting enter?
Or do you expect all the images start with "DOWNLOADS_etc.png"?
Sorry for the delayed response but essentially I am attempting to see how many files are in the folder, and name it that number plus 1, of which I am currently attempting to figure out
That's already what lines 250-265 do
` if FileExist(Store) { ;;msgbox, "%Store%" exists loop, 100 { StoreTemp = %StoreT%%A_Space%(%A_Index%).%ext% ;;msgbox, %StoreTemp%
found := A_Index if !FileExist(StoreTemp) { win = 1 Store := StoreTemp break } } `
If the number of duplicates are greater than 100. It proceeds to generate a random 12 character length name. And repeats that for infinity until it finds a non existing file like this
XAEFOOERKLQ.jpg (or whatever the extension of the file has been deemed as)
Is it not functioning?
I was noticing that, yea though I am guessing that's the part that adds ("number of duplicates") to the end of the file name?
It's exactly how Windows default image save operates. It is the exact same formatting. Is 100 too low of a number before it gives up? and goes to the 12 char stuff?
Then just raise the number to anything you like. loop, 2147483647
No it's not that, apologies I believe there's been a slight miscommunication, I am only going to be setting the file name directly too that number, e.g. I save a photo, and if there's already 3 files in the directory it will name it to 4.png, and so on
Assuming it's not doing a complicated file comparison (HASH check) it can check 1-~ in it's OWN file type (jpg png bmp) in that range of 1-100 or whatever you set it's max to
StoreTemp = %StoreT%%A_Space%(%string%).%ext% . should look like this I believe. . StoreTemp = %string%.%ext%
We can easily make it better than that if you like. It's a trivial fix for me. Much easier than any of the upgrades I'm trying to do to do to the next generation of someone elses programs...
If your okay with it, that would be lovely, as I am not familiar with how AutoHotkey operates just yet
What do you require mister?
Essentially what I am ultimately needing is for me to be able to have it so that when it downloads the file, it will check "Default" directory for any files, in this case there would only be photos, all of which have the extension of ".png", and ultimately name the file the total of files +1 so if there is 2 photos in the directory it will be name "3.png", and if I saved another it would be named "4.png" and so forth, hopefully that makes sense, as I am terrible at explaining things half the time
I have discord as my primary use if that works?
Sounds good. Give me your @ bit
I can think of too many exceptions to what you might need to be prepared for.
I'll be closing this issue since it seems the issue was fixed (or at least is being fixed off-github :))
Was hoping there was a tutorial for being able to download stuff, e.g. pictures