Skip to content

Commit 0b6c75e

Browse files
fralkenchewitt
authored andcommitted
fix syntax and deprecation warnings
Original pull request from MilhouseVH repo: MilhouseVH#78
1 parent ca99328 commit 0b6c75e

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

texturecache.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def __init__(self, argv):
105105
self.SetJSONVersion(0, 0, 0)
106106

107107
namedSection = False
108-
serial_urls = "assets\.fanart\.tv"
108+
serial_urls = r"assets\.fanart\.tv"
109109
embedded_urls = "^video, ^music, ^DefaultVideo.png"
110110

111111
if MyUtility.isPython3:
@@ -356,9 +356,9 @@ def __init__(self, argv):
356356
# Fix patterns as we now strip image:// from the URLs, so we need to remove
357357
# this prefix from any legacy patterns that may be specified by the user
358358
for index, r in enumerate(self.CACHE_IGNORE_TYPES):
359-
self.CACHE_IGNORE_TYPES[index] = re.compile(re.sub("^\^image://", "^", r.pattern))
359+
self.CACHE_IGNORE_TYPES[index] = re.compile(re.sub(r"^\^image://", "^", r.pattern))
360360
for index, r in enumerate(self.PRUNE_RETAIN_TYPES):
361-
self.PRUNE_RETAIN_TYPES[index] = re.compile(re.sub("^\^image://", "^", r.pattern))
361+
self.PRUNE_RETAIN_TYPES[index] = re.compile(re.sub(r"^\^image://", "^", r.pattern))
362362

363363
self.PRUNE_RETAIN_PREVIEWS = self.getBoolean(config, "prune.retain.previews", "yes")
364364
self.PRUNE_RETAIN_PICTURES = self.getBoolean(config, "prune.retain.pictures", "no")
@@ -1283,7 +1283,7 @@ def run(self):
12831283
elif "tvshowid" in item:
12841284
libid = item["tvshowid"]
12851285
if year and title.endswith("(%d)" % year):
1286-
title = re.sub("\(%d\)$" % year, "", title).strip()
1286+
title = re.sub(r"\(%d\)$" % year, "", title).strip()
12871287
isTVShow = True
12881288
elif "episodeid" in item:
12891289
libid = item["episodeid"]
@@ -2092,8 +2092,8 @@ def logreplay_mapthread(self, map_to_thread=None):
20922092
tpattern = map_to_thread
20932093
self.config.log_replay_tmap[map_to_thread] = thread
20942094

2095-
self.web_re_result = re.compile("^.*:(%s)[ ]*: .*\.RECEIVED WEB DATA: ([0-9]*), (.*), (.*)$" % tpattern)
2096-
self.json_re_result = re.compile("^.*:(%s)[ ]*: .*\.PARSING JSON DATA: (.*)$" % tpattern)
2095+
self.web_re_result = re.compile(r"^.*:(%s)[ ]*: .*\.RECEIVED WEB DATA: ([0-9]*), (.*), (.*)$" % tpattern)
2096+
self.json_re_result = re.compile(r"^.*:(%s)[ ]*: .*\.PARSING JSON DATA: (.*)$" % tpattern)
20972097

20982098
# If the thread data being processed is mapped to a thread other than the current
20992099
# thread then ignore this thread data
@@ -3939,7 +3939,7 @@ def setState(self, HAS_RESUME, playcount, lastplayed, resume):
39393939
class MyUtility(object):
39403940
isPython3 = (sys.version_info >= (3, 0))
39413941
isPython3_1 = (sys.version_info >= (3, 1))
3942-
EPOCH = datetime.datetime.utcfromtimestamp(0)
3942+
EPOCH = datetime.datetime.fromtimestamp(0, datetime.UTC)
39433943

39443944
DCData = {}
39453945
DCStats = {}
@@ -3950,8 +3950,8 @@ class MyUtility(object):
39503950
#<regexp>(.*?)([ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[0-9]+)(.*?)(\.[^.]+)$</regexp>
39513951
#<!-- <cd/dvd/part/pt/disk/disc> <a-d> -->
39523952
#<regexp>(.*?)([ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[a-d])(.*?)(\.[^.]+)$</regexp>
3953-
RE_STACKING_1_9 = re.compile("(.*?)([ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[0-9]+)(.*?)(\.[^.]+)$", flags=re.IGNORECASE)
3954-
RE_STACKING_A_D = re.compile("(.*?)([ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[a-d])(.*?)(\.[^.]+)$", flags=re.IGNORECASE)
3953+
RE_STACKING_1_9 = re.compile(r"(.*?)([ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[0-9]+)(.*?)(\.[^.]+)$", flags=re.IGNORECASE)
3954+
RE_STACKING_A_D = re.compile(r"(.*?)([ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[a-d])(.*?)(\.[^.]+)$", flags=re.IGNORECASE)
39553955

39563956
RE_NOT_DIGITS = re.compile("[^0123456789]")
39573957

@@ -4133,7 +4133,7 @@ def Top250MovieList():
41334133

41344134
table = ET.fromstring(newdata)
41354135

4136-
RE_IMDB = re.compile("/movie/\?([0-9]*)")
4136+
RE_IMDB = re.compile(r"/movie/\?([0-9]*)")
41374137

41384138
movies = {}
41394139
for row in table:
@@ -5108,7 +5108,7 @@ def parseURLData(jcomms, mediatype, mediaitems, imagecache, data, title_name, id
51085108
mediatype = "tvshows"
51095109
name = showName
51105110
if season:
5111-
episode = re.sub("([0-9]*x[0-9]*)\..*", "\\1", title)
5111+
episode = re.sub(r"([0-9]*x[0-9]*)\..*", "\\1", title)
51125112
longName = "%s, %s Episode %s" % (showName, season, episode)
51135113
else:
51145114
season = title
@@ -5243,7 +5243,7 @@ def qaData(mediatype, jcomms, database, data, title_name, id_name, rescan, work=
52435243

52445244
if showName:
52455245
if season:
5246-
episode = re.sub("([0-9]*x[0-9]*)\..*", "\\1", title)
5246+
episode = re.sub(r"([0-9]*x[0-9]*)\..*", "\\1", title)
52475247
name = "%s, %s Episode %s" % (showName, season, episode)
52485248
else:
52495249
episode = None
@@ -5474,7 +5474,7 @@ def missingFiles(mediatype, data, fileList, title_name, id_name, showName=None,
54745474
if showName:
54755475
name = showName
54765476
if season:
5477-
episode = re.sub("([0-9]*x[0-9]*)\..*", "\\1", title)
5477+
episode = re.sub(r"([0-9]*x[0-9]*)\..*", "\\1", title)
54785478
name = "%s, %s Episode %s" % (showName, season, episode)
54795479
else:
54805480
season = title
@@ -5533,7 +5533,7 @@ def queryLibrary(mediatype, query, data, title_name, id_name, work=None, mitems=
55335533

55345534
if showName:
55355535
if season:
5536-
episode = re.sub("([0-9]*x[0-9]*)\..*", "\\1", title)
5536+
episode = re.sub(r"([0-9]*x[0-9]*)\..*", "\\1", title)
55375537
name = "%s, %s Episode %s" % (showName, season, episode)
55385538
else:
55395539
episode = None
@@ -5759,7 +5759,7 @@ def watchedBackup(mediatype, filename, data, title_name, id_name, work=None, mit
57595759
if showName:
57605760
shortName = showName
57615761
if season:
5762-
episode_year = re.sub("([0-9]*x[0-9]*)\..*", "\\1", title)
5762+
episode_year = re.sub(r"([0-9]*x[0-9]*)\..*", "\\1", title)
57635763
longName = "%s, %s Episode %s" % (showName, season, episode_year)
57645764
else:
57655765
episode_year = None
@@ -5810,7 +5810,7 @@ def watchedRestore(mediatype, jcomms, filename, data, title_name, id_name, work=
58105810
if showName:
58115811
shortName = showName
58125812
if season:
5813-
episode_year = re.sub("([0-9]*x[0-9]*)\..*", "\\1", title)
5813+
episode_year = re.sub(r"([0-9]*x[0-9]*)\..*", "\\1", title)
58145814
longName = "%s, %s Episode %s" % (showName, season, episode_year)
58155815
else:
58165816
episode_year = None
@@ -5981,7 +5981,7 @@ def updateIMDb(mediatype, jcomms, data):
59815981

59825982
episode["imdbnumber"] = tvhash[tvshow["tvshowid"]]["imdbnumber"]
59835983

5984-
SxE = re.sub("[0-9]*x([0-9]*)\..*", "\\1", episode["label"])
5984+
SxE = re.sub(r"[0-9]*x([0-9]*)\..*", "\\1", episode["label"])
59855985
if SxE == episode["label"] or int(SxE) < 1: continue
59865986

59875987
file = episode.get("file", None)
@@ -6035,7 +6035,7 @@ def _ProcessIMDB(mediatype, jcomms, data, plotFull, plotOutline, movies250, imdb
60356035
re_map_titles = []
60366036
re_trans_titles = []
60376037
re_trans_years = []
6038-
re_parenthesis = re.compile("\([a-zA-Z]*\)$")
6038+
re_parenthesis = re.compile(r"\([a-zA-Z]*\)$")
60396039

60406040
for ft in gConfig.IMDB_IGNORE_TVTITLES:
60416041
re_ignore_titles.append(re.compile(ft, re.IGNORECASE))
@@ -6095,7 +6095,7 @@ def _ProcessIMDB(mediatype, jcomms, data, plotFull, plotOutline, movies250, imdb
60956095
# Remove original year from end of title
60966096
if tvshow["tc.year"] is not None and tvshow["title"].endswith("(%d)" % tvshow["tc.year"]):
60976097
before_title = tvshow["title"]
6098-
tvshow["title"] = re.sub("\(%d\)$" % tvshow["tc.year"], "", tvshow["title"]).strip()
6098+
tvshow["title"] = re.sub(r"\(%d\)$" % tvshow["tc.year"], "", tvshow["title"]).strip()
60996099
gLogger.log("Pre-processing #4 OMDb: Title: [%s] removing year from title, giving [%s]" % (before_title, tvshow["title"]))
61006100

61016101
# Remove trailing parenthesis (...) from end of title - most likely to be a country code
@@ -6790,7 +6790,7 @@ def getAllFiles(keyFunction):
67906790
]
67916791

67926792
for r in REQUEST:
6793-
mediatype = re.sub(".*\.Get(.*)","\\1",r["method"])
6793+
mediatype = re.sub(r".*\.Get(.*)","\\1",r["method"])
67946794

67956795
if gConfig.CACHE_EXTRA and mediatype == "Movies":
67966796
jcomms.addProperties(r, "file")
@@ -7063,7 +7063,7 @@ def addItems(item, mediatype, idname):
70637063
]
70647064

70657065
for r in REQUEST:
7066-
mediatype = re.sub(".*\.Get(.*)","\\1",r["method"])
7066+
mediatype = re.sub(r".*\.Get(.*)","\\1",r["method"])
70677067
idname = idnames[mediatype]
70687068
mtype = types[mediatype]
70697069

0 commit comments

Comments
 (0)