diff options
| author | 2019-12-25 19:40:29 -0500 | |
|---|---|---|
| committer | 2019-12-25 19:40:29 -0500 | |
| commit | d9cde490ce957f56cd2bb9e1628c2c0ef1a8733b (patch) | |
| tree | 13f58a5c602ae402a6b1fc598ce227e9f36f3aa2 /gallery_dl/util.py | |
| parent | f9b17d9842e84709e2a41e92eb1dff0654c430c5 (diff) | |
| parent | f9a1a9dcb7df977eeac9544786df9c0b93795815 (diff) | |
Update upstream source from tag 'upstream/1.12.1'
Update to upstream version '1.12.1'
with Debian dir 6bd6e3209b21195bb26b892f2d85b1324de1f0d9
Diffstat (limited to 'gallery_dl/util.py')
| -rw-r--r-- | gallery_dl/util.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/gallery_dl/util.py b/gallery_dl/util.py index fb51edf..48ae0be 100644 --- a/gallery_dl/util.py +++ b/gallery_dl/util.py @@ -78,6 +78,11 @@ def transform_dict(a, func): a[key] = func(value) +def filter_dict(a): + """Return a copy of 'a' without "private" entries""" + return {k: v for k, v in a.items() if k[0] != "_"} + + def number_to_string(value, numbers=(int, float)): """Convert numbers (int, float) to string; Return everything else as is.""" return str(value) if value.__class__ in numbers else value @@ -665,17 +670,17 @@ class PathFormat(): self.temppath = self.realpath = self.realpath[:-1] return True - def build_path(self): - """Use filename metadata and directory to build a full path""" - - # Apply 'kwdict' to filename format string + def build_filename(self): + """Apply 'kwdict' to filename format string""" try: - self.filename = filename = self.clean_path(self.clean_segment( + return self.clean_path(self.clean_segment( self.filename_formatter(self.kwdict))) except Exception as exc: raise exception.FilenameFormatError(exc) - # Combine directory and filename to full paths + def build_path(self): + """Combine directory and filename to full paths""" + self.filename = filename = self.build_filename() self.path = self.directory + filename self.realpath = self.realdirectory + filename if not self.temppath: @@ -743,13 +748,13 @@ class DownloadArchive(): def __contains__(self, kwdict): """Return True if the item described by 'kwdict' exists in archive""" - key = self.keygen(kwdict) + key = kwdict["_archive_key"] = self.keygen(kwdict) self.cursor.execute( "SELECT 1 FROM archive WHERE entry=? LIMIT 1", (key,)) return self.cursor.fetchone() def add(self, kwdict): """Add item described by 'kwdict' to archive""" - key = self.keygen(kwdict) + key = kwdict.get("_archive_key") or self.keygen(kwdict) self.cursor.execute( "INSERT OR IGNORE INTO archive VALUES (?)", (key,)) |
