Mercurial > codedump
diff getlist.py @ 118:eac6dae753ca
*: major cleanup
committer: GitHub <noreply@github.com>
author | Paper <37962225+mrpapersonic@users.noreply.github.com> |
---|---|
date | Fri, 03 Mar 2023 22:51:28 +0000 |
parents | 37f231f85a67 |
children |
line wrap: on
line diff
--- a/getlist.py Fri Mar 03 22:33:53 2023 +0000 +++ b/getlist.py Fri Mar 03 22:51:28 2023 +0000 @@ -1,6 +1,7 @@ import urllib.request import json import sys +from yt_dlp.utils import sanitize_filename # Initialize variables # https://github.com/xbmc/metadata.themoviedb.org.python/blob/master/python/lib/tmdbscraper/tmdbapi.py#L36 @@ -46,8 +47,7 @@ with urllib.request.urlopen(f'https://api.themoviedb.org/3/tv/{str(id)}/season/{season}/episode/{count}?api_key={key}') as url: data = json.loads(url.read().decode()) f = open("list.txt", "a", encoding="utf-8") - f.write(data["name"].replace("?", "?").replace( - ":", "꞉").replace('"', "“").split("/")[0].rstrip() + "\n") + f.write(sanitize_filename(data["name"], restricted=True) + "\n") count += 1 f.close() if source == 'mal': @@ -59,7 +59,6 @@ f.close() for i in range(len(data["episodes"])): f = open("list.txt", "a", encoding="utf-8") - f.write(data["episodes"][count]["title"].replace("?", "?").replace( - ":", "꞉").replace('"', "“").split("/")[0].rstrip() + "\n") + f.write(sanitize_filename(data["episodes"][count]["title"], restricted=True) + "\n") count += 1 f.close()