mikf / gallery-dl

Command-line program to download image galleries and collections from several image hosting sites
GNU General Public License v2.0
11.7k stars 953 forks source link

Some questions about Newgrounds #1165

Closed musjj closed 3 years ago

musjj commented 3 years ago

I have some questions about the default filename and directory format in the Newgrounds extractor. Why is the index keyword prefixed with an underscore? What exactly is it for? {category}_{_index}_{title}.{extension} Also, why is the artist keyword a list? Can more than one artist be credited in an artwork? Lastly, can you how does this format string work: ["{category}", "{artist[:10]:J, }"] I looked through the documentation for Python's format string syntax but I can't find any mention of it. I'm assuming gallery-dl is using its own custom string formatter. If so, are there any documentation for it?

mikf commented 3 years ago

Why is the index keyword prefixed with an underscore? What exactly is it for?

I needed some way to keep backwards compatibility for newgrounds archive keys when adding support for embedded images (https://github.com/mikf/gallery-dl/commit/c5e3971b186f68d8529df33e369b9e6085ec5b7d), so I added a "private" _index keyword that behaves like the normal index for the main file of a post, but looks a bit different for any additional embedded ones.

It is possible to get the same effect in the filename format string with {index}{num:?_//}, but not for the archive format string since that can only use the regular format string syntax.

Also, why is the artist keyword a list? Can more than one artist be credited in an artwork?

Maybe not artworks, but quite a lot of videos have more than one user in the "Credits & Info" section. This one for example has three: https://www.newgrounds.com/portal/view/595355.

Lastly, can you how does this format string work:

It takes the first 10 elements of the artist list (artist[:10]) and Joins those with , as separator (:J,) using str.join

I'm assuming gallery-dl is using its own custom string formatter. If so, are there any documentation for it?

It is using its own formatter. The only documentation for it is currently in the doc strings here, mostly because I'm lazy, but also because there will most likely be a rework of the whole custom format string syntax in 2.0 and I wanted to wait until then.

Hrxn commented 3 years ago

Mostly because we're all lazy :)

J20X9 commented 3 years ago

It is possible to get the same effect in the filename format string with {index}{num:?_//}, but not for the archive format string since that can only use the regular format string syntax.

Ah, I was wondering how to properly number embedded images, I couldn't figure out how to use num without getting None added to the first, non-embedded, image. It would have been really handy knowing how the custom string formatter worked a long time ago.

musjj commented 3 years ago

Thank you for the detailed explanation! That docstring is definitely super useful in the future for cases like this.

musjj commented 3 years ago

Actually, I have one more question. Are there any benefits to providing a login to gallery-dl? It seems that Newgrounds doesn't hide any kind of submissions even if you're logged out.

mikf commented 3 years ago

Some posts (probably only flash games) require a login to be accessible: (nsfw) https://www.newgrounds.com/portal/view/697555

musjj commented 3 years ago

Ah I see, thanks for the clarification!