From 4cb2d0e78aaf06e95759d62a03010d8a2664aec2 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 7 Jan 2024 20:24:35 -0500 Subject: [PATCH] metadata/Music: remove unused external dependency on simplejson The simplejson module was added to the python standard library in 2.6; here, it is inconsistently imported for python 2.6 (where it already exists) and lower (where it does not) instead of using `json`. But, mythtv only supports python 3.8 for a while now. So this conditional is merely dead code. The import name is still aliased using `as simplejson`, though, which is bad for visibility and analysis. --- mythtv/programs/scripts/metadata/Music/lyrics/genius.py | 5 ++--- .../programs/scripts/metadata/Music/lyrics/lyricswiki.py | 9 ++------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/mythtv/programs/scripts/metadata/Music/lyrics/genius.py b/mythtv/programs/scripts/metadata/Music/lyrics/genius.py index fb73728c0ba..fa212aad872 100644 --- a/mythtv/programs/scripts/metadata/Music/lyrics/genius.py +++ b/mythtv/programs/scripts/metadata/Music/lyrics/genius.py @@ -20,7 +20,7 @@ from optparse import OptionParser from common import utilities -import json as simplejson +import json __author__ = "Paul Harrison and ronie'" __title__ = "Genius" @@ -50,7 +50,7 @@ def get_lyrics(self, lyrics): return False req.close() - data = simplejson.loads(response) + data = json.loads(response) try: name = data['response']['hits'][0]['result']['primary_artist']['name'] @@ -198,4 +198,3 @@ def main(): if __name__ == '__main__': main() - diff --git a/mythtv/programs/scripts/metadata/Music/lyrics/lyricswiki.py b/mythtv/programs/scripts/metadata/Music/lyrics/lyricswiki.py index c6fe1f2079b..8b1a2d1f61d 100644 --- a/mythtv/programs/scripts/metadata/Music/lyrics/lyricswiki.py +++ b/mythtv/programs/scripts/metadata/Music/lyrics/lyricswiki.py @@ -1,6 +1,6 @@ #-*- coding: UTF-8 -*- -import sys, re, socket +import json, sys, re, socket try: from urllib2 import quote, urlopen, HTTPError @@ -15,11 +15,6 @@ from optparse import OptionParser -if sys.version_info < (2, 7): - import simplejson -else: - import json as simplejson - from common import * __author__ = "Paul Harrison and ronie'" @@ -49,7 +44,7 @@ def get_lyrics(self, lyrics): except: return False req.close() - data = simplejson.loads(response) + data = json.loads(response) try: self.page = data['url'] except: