Skip to content

Commit

Permalink
Merge pull request #96 from CollinHeist/develop
Browse files Browse the repository at this point in the history
Add option to change font size on genre cards, retry TMDb API requests
  • Loading branch information
CollinHeist authored Apr 28, 2022
2 parents 253ef8d + 2457e32 commit 0a687f2
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 97 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ titlecase = "*"
tqdm = "*"
fonttools = "*"
plexapi = "*"
tenacity = "*"

[dev-packages]

Expand Down
166 changes: 87 additions & 79 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion fixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
source=Path(args.genre_card[0]),
genre=args.genre_card[1],
output=Path(args.genre_card[2]),
font_size=float(args.font_size[:-1])/100.0,
).create()

if hasattr(args, 'genre_card_batch'):
Expand All @@ -182,7 +183,8 @@
GenreMaker(
source=file,
genre=file.stem.upper(),
output=Path(file.parent / f'{file.stem}-GenreCard{file.suffix}'),
output=Path(file.parent /f'{file.stem}-GenreCard{file.suffix}'),
font_size=float(args.font_size[:-1])/100.0,
).create()

# Execute Sonarr related options
Expand Down
2 changes: 1 addition & 1 deletion modules/Debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

"""TQDM bar format string"""
TQDM_KWARGS = {
'bar_format': ('{desc}: {percentage:3.0f}%|{bar}| {n_fmt}/{total_fmt} '
'bar_format': ('{desc} {percentage:3.0f}%|{bar}| {n_fmt}/{total_fmt} '
'[{elapsed}, {rate_fmt}{postfix}]'),
'leave': False,
}
Expand Down
23 changes: 12 additions & 11 deletions modules/GenreMaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,25 @@ class GenreMaker(ImageMaker):
__SOURCE_WITH_GRADIENT = ImageMaker.TEMP_DIR / 'swg.png'


def __init__(self, source: Path, genre: str, output: Path) -> None:
def __init__(self, source: Path, genre: str, output: Path,
font_size: float=1.0) -> None:
"""
Constructs a new instance.
:param source: The source image to use for the genre card.
:param genre: The genre text to put on the genre card.
:param output: The output path to write the genre card to.
:param source: The source image to use for the genre card.
:param genre: The genre text to put on the genre card.
:param output: The output path to write the genre card to.
:param font_size: Scalar to apply to the title font size.
"""

# Initialize parent object for the ImageMagickInterface
super().__init__()

# Store this image's source, genre, and output arguments
# Store the arguments
self.source = source
self.genre = genre
self.output = output
self.font_size = font_size


def __resize_source(self) -> Path:
Expand Down Expand Up @@ -94,19 +95,19 @@ def __add_text_and_border(self, source_with_gradient: Path) -> Path:
:param source_with_gradient: The source image with the gradient
applied.
:returns: Path to the created image.
:returns: Path to the created image (the output file).
"""

command = ' '.join([
f'convert "{source_with_gradient.resolve()}"',
f'-gravity south',
f'-gravity center',
f'-font "{self.FONT.resolve()}"',
f'-bordercolor white',
f'-border 27x27',
f'-fill white',
f'-pointsize 159',
f'-pointsize {self.font_size * 159}',
f'-kerning 2.25',
f'-annotate +0+100 "{self.genre}"',
f'-annotate +0+564 "{self.genre}"',
f'"{self.output.resolve()}"',
])

Expand Down
2 changes: 1 addition & 1 deletion modules/PlexInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def set_title_cards_for_series(self, library_name: str,
for episode in (pbar := tqdm(series.episodes(), leave=False)):
# Update progress bar
pbar.set_description(f'Updating {episode.seasonEpisode.upper()}')

# If this Plex episode is among the list of cards to update
ep_key = f'{episode.parentIndex}-{episode.index}'
if ep_key in filtered_episodes:
Expand Down
3 changes: 1 addition & 2 deletions modules/StandardTitleCard.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ def __init__(self, source: Path, output_file: Path, title: str,
:param font: Font to use for the episode title. MUST be a
a valid ImageMagick font, or filepath to a
font.
:param font_size: Scalar to apply to the standard font size,
i.e. 1.0 if normal (100%), 0.5 if 50%, etc.
:param font_size: Scalar to apply to the title font size.
:param title_color: Color to use for the episode title.
:param hide_season: Whether to omit the season text (and joining
character) from the title card completely.
Expand Down
2 changes: 1 addition & 1 deletion modules/Template.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __recurse_priority_union(self, base_yaml: dict,
>>> base_yaml
{'a': 123, 'b': 234, 'c': {'c1': False, 'c2': True}}
:param base_yaml: The base - i.e. higher priority, YAML that
:param base_yaml: The base - i.e. higher priority - YAML that
forms the basis of the union of these
dictionaries. Modified in-place.
:param template_yaml: The templated - i.e. lower priority - YAML.
Expand Down
Loading

0 comments on commit 0a687f2

Please sign in to comment.