Skip to content

Commit

Permalink
[deviantart] refactor base36 conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
ClosedPort22 committed Jan 23, 2023
1 parent 293abb8 commit 674c719
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions gallery_dl/extractor/deviantart.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ def prepare(self, deviation):
)

# filename metadata
alphabet = "0123456789abcdefghijklmnopqrstuvwxyz"
deviation["index_base36"] = util.bencode(deviation["index"], alphabet)
deviation["index_base36"] = base36_from_id(deviation["index"])
sub = re.compile(r"\W").sub
deviation["filename"] = "".join((
sub("_", deviation["title"].lower()), "_by_",
Expand Down Expand Up @@ -1564,6 +1563,17 @@ def _login_impl(extr, username, password):
}


def id_from_base36(base36):
return util.bdecode(base36, _ALPHABET)


def base36_from_id(deviation_id):
return util.bencode(int(deviation_id), _ALPHABET)


_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz"


###############################################################################
# Journal Formats #############################################################

Expand Down

0 comments on commit 674c719

Please sign in to comment.