4pr0n / ripme

Downloads albums in bulk
MIT License
916 stars 203 forks source link

During gallery/folder ripping the DeviantArt avatar fetching fails with 404 due to an old hardcoded address #577

Open rautamiekka opened 7 years ago

rautamiekka commented 7 years ago

NOTE: Syntax as understood as of 2017-06-18 at https://github.com/4pr0n/ripme/issues/577#issuecomment-309268167

Gave it a while to see if it would just go away as an error on DA's end, but since it wouldn't I checked the site's source code which confirmed the avatar address is a little different from what's hardcoded into RipMe:

Old=http://a.deviantart.net/avatars/o/USERNAME.gif?11 New=http://a.deviantart.net/avatars/l/o/USERNAME.gif?11

My guess is the trailing ?11 is some sorta spot-specific instruction for the GIF, in which case dropping that part would be in our best interest.

metaprime commented 7 years ago

@rautamiekka I'm getting 404 on your "New" link, even when I change USERNAME to an actual username. Can you provide a set of links that demonstrate this problem and the link you were trying to rip when it occurred?

rautamiekka commented 7 years ago

You're right, even the new link is wrong, and now when looked at it again I see the problem: the leading http://a.deviantart.net/avatars/ part is static and the rest is completely predictable but depends on the username.

For example, suppose your name is

It takes your first letter for the first folder, then the second letter for the second folder, and your whole username with the .gif extension for the filename. In the case of higglytownhero his name is capitalized as HigglyTownHero, so the usernames in links are always lower-case but the case matters in only filenames.

Notice that the trailing integer parts are different from the links in the OP, and quickly checking around (opening up many avatars in succession) it appears the integer is an avatar type indicator since the integer is same across users with similar avatars.

metaprime commented 7 years ago

appears the integer is an avatar type indicator since the integer is same across users with similar avatars.

Is this integer also predictable? Perhaps it's the user account type (indicated on the site with a symbol before the name like ~ or =)?

rautamiekka commented 7 years ago

^ No, it's not user account type indicator and it should be safe to say it has no ties to it either.

For example:

rautamiekka commented 7 years ago

Sitrep: I couldn't get any versions to spontaneously repeat the avatar fetch failure, but just very recently after literally a couple dozen folders, 1.5.2 started to fail (only the avatar fetching) and these are what I have left since RipMe GUI repeatedly totally froze after being left minimized for extended periods (which is a problem with the particular computer I were using before reinstalling my main one):

Downloading http://a.deviantart.net/avatars/l/mlp-and-anime-rock.jpg?12
http://a.deviantart.net/avatars/l/mlp-and-anime-rock.jpg?12 : Non-retriable status code 404 while downloading http://a.deviantart.net/avatars/l/mlp-and-anime-rock.jpg?12
Downloading http://a.deviantart.net/avatars/n/andoanimalia.png?3
http://a.deviantart.net/avatars/n/andoanimalia.png?3 : Non-retriable status code 404 while downloading http://a.deviantart.net/avatars/n/andoanimalia.png?3
Downloading http://a.deviantart.net/avatars/h/thepossumface.png
http://a.deviantart.net/avatars/h/thepossumface.png : Non-retriable status code 404 while downloading http://a.deviantart.net/avatars/h/thepossumface.png
Downloading http://a.deviantart.net/avatars/a/karpy96.png?3
http://a.deviantart.net/avatars/a/karpy96.png?3 : Non-retriable status code 404 while downloading http://a.deviantart.net/avatars/a/karpy96.png?3

It uses the username's 2nd letter for the first subfolder, doesn't use the 2nd subfolder at all, and uses JPG, PNG or GIF (not seen in this output) for the format. This output is the first when I see RipMe using other than GIF for the avatar file format.

rautamiekka commented 7 years ago

This thing gets more complicated:

Indeed, there are users with an username of a single character, like

So for some reason at least 1 user, who's been offline for 300 weeks, still has an JPG avatar with a trailing integer while the other has a GIF without the integer but offline period is a secret, but it's obvious he's been offline for really long too.

So when your username is only 1 character long, DeviantArt uses that one character for the folder and the username with an extension for the filename. Otherwise same but the first 2 characters of the username for the 2 folders.

There are other users' avatars on almost every page, so using a RegEx to catch just the target user's is impossible, therefore it's best to construct the link in app.