Skip to content

Commit

Permalink
adds id-title filename handler
Browse files Browse the repository at this point in the history
  • Loading branch information
beaufour committed Nov 8, 2022
1 parent b1804c2 commit b0af9be
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions flickr_download/filename_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ def title_and_id(pset: Optional[Photoset], photo: Photo, suffix: Optional[str])
return get_filename(f"{photo.title}-{photo.id}{suffix}")


def id_and_title(pset: Optional[Photoset], photo: Photo, suffix: Optional[str]) -> str:
"""Name file after photo id and title.
@param pset: Flickr.Photoset, the photoset
@param photo: Flickr.Photo, the photo
@param suffix: str, optional suffix
@return: str, the filename
"""
if not photo.title:
return idd(pset, photo, suffix)

return get_filename(f"{photo.id}-{photo.title}{suffix}")


INCREMENT_INDEX: Dict[Any, Any] = defaultdict(lambda: defaultdict(int))
"""Photoset -> filename index for title_increment function duplicate tracking"""

Expand Down Expand Up @@ -90,6 +104,7 @@ def title_increment(pset: Optional[Photoset], photo: Photo, suffix: Optional[str
"title": title,
"id": idd,
"title_and_id": title_and_id,
"id_and_title": id_and_title,
"title_increment": title_increment,
}

Expand Down

0 comments on commit b0af9be

Please sign in to comment.