Voldrix / onlyfans-dl-2

OnlyFans content downloader v2
GNU General Public License v3.0
151 stars 23 forks source link

Photos and videos in messages or purchased not in albums don't have date in filename #45

Closed blmatthews closed 2 years ago

blmatthews commented 2 years ago

When downloading photos and videos in messages, if there are multiple photos or videos in a message and ALBUMS is True, photos are written to messages/photos/\-\/\-\.\, and videos to messages/videos/..., as expected. However, if a message only contains a single photo (or video), it's written to messages/photos/\.\, with no date (and similar for videos except under messages/videos). Posted photos and videos, on the other hand, always have the date in the filename, regardless of whether they're in a subdirectory or not. It would be nice if photos and videos in messages were named the same way as in posts.

Looking at the code, the base problem is that the data structures for post media and message media are different (of course they are! sighs and shakes head), so download_media can use media['createdAt'] for post media but not message media. For that it gets the date from album, but that only works if album isn't False (i.e. ALBUMS is True and there's more than one media in the message.) If it is, it just uses the id.

While I haven't tried this, I think the most straightforward fix might be to have download_media take the date as a parameter. Then it can always add the date to the filename, and doesn't have to assume the contents of album. The only function calling download_media is get_content, and it's already doing some stuff to get the date for the album, so it would seem logical to have something in the for loop starting at line 205 to get the date for the media. Or maybe not, I've only looked at it a bit.

Note that I think the same issue happens with purchased media, although my only purchase included two things. However, they're handled the same as messages, so fixing the issue for messages should fix it for purchases as well.

Voldrix commented 2 years ago

That was a little messy. I separated the date from the album ID and pass them as two separate parameters now like you suggested. Now everything should have congruent nomenclature.

blmatthews commented 2 years ago

Looks good! Yeah, a little messy, but not too bad. I downloaded everything and it worked fine, everything has dates in the names now. Of course, again, I only subscribe to one profile, although it has everything except stories, so it's not an extensive test, but not bad either. Thanks!