diff options
| author | 2019-12-25 19:40:28 -0500 | |
|---|---|---|
| committer | 2019-12-25 19:40:28 -0500 | |
| commit | f9a1a9dcb7df977eeac9544786df9c0b93795815 (patch) | |
| tree | 8cb69cf7685da8d7e4deb7dc1d6b209098e1ddfb /gallery_dl/util.py | |
| parent | 0c73e982fa596da07f23b377621ab894a9e64884 (diff) | |
New upstream version 1.12.1upstream/1.12.1
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,)) |
