Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ihabunek committed Sep 1, 2024
1 parent f565dd0 commit 1c97a2f
Show file tree
Hide file tree
Showing 6 changed files with 260 additions and 332 deletions.
214 changes: 0 additions & 214 deletions fonts.py

This file was deleted.

20 changes: 3 additions & 17 deletions twitchdl/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Optional

from twitchdl.http import download_file
from twitchdl.output import print_status

CACHE_SUBFOLDER = "twitch-dl"

Expand All @@ -18,7 +19,7 @@ def download_cached(
*,
filename: Optional[str] = None,
subfolder: Optional[str] = None,
) -> Optional[Path]:
) -> Path:
cache_dir = get_cache_dir()
target_dir = cache_dir / subfolder if subfolder else cache_dir
target_dir.mkdir(parents=True, exist_ok=True)
Expand All @@ -28,27 +29,12 @@ def download_cached(
target = target_dir / filename

if not target.exists():
print_status(f"Downloading {url}", dim=True)
download_file(url, target)

return target


def get_text_font() -> Path:
url = "https://cdn.jsdelivr.net/gh/notofonts/notofonts.github.io/fonts/NotoSans/full/ttf/NotoSans-Light.ttf"
path = download_cached(url, subfolder="fonts", filename="NotoSans-Light.ttf")
if not path:
raise ValueError(f"Failed downloading font from {url}")
return path


def get_noto_color_emoji_font() -> Path:
url = "https://github.com/googlefonts/noto-emoji/raw/main/fonts/NotoColorEmoji.ttf"
path = download_cached(url, subfolder="fonts", filename="NotoColorEmoji.ttf")
if not path:
raise ValueError(f"Failed downloading font from {url}")
return path


def get_cache_dir() -> Path:
path = _cache_dir_path()
path.mkdir(parents=True, exist_ok=True)
Expand Down
Loading

0 comments on commit 1c97a2f

Please sign in to comment.