diff --git a/CHANGES.md b/CHANGES.md index 0b3508b9..e4fab194 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,7 +4,6 @@ * Add failed database to unit tests tear down function * Fix purging of database files in tear down function during unit tests * Add ability to auto focus Search Show box on Home page and control this option via General Config/Interface -* Add TVRage network name standardization * Change some provider images. Add a few new images * Remove redundant Coming Eps template code used in the old UI * Change update Plex notifier (port from SickBeard) @@ -14,6 +13,8 @@ * Remove legacy sickbeard updater and build automation code [develop changelog] +* Add TVRage network name standardization +* Remove TVRage network name standardization ### 0.4.0 (2014-12-04 10:50:00 UTC) diff --git a/lib/tvrage_api/tvrage_api.py b/lib/tvrage_api/tvrage_api.py index b5347bdf..95a49811 100644 --- a/lib/tvrage_api/tvrage_api.py +++ b/lib/tvrage_api/tvrage_api.py @@ -22,7 +22,6 @@ import datetime as dt import requests import requests.exceptions import xmltodict -from sickbeard.network_timezones import standardize_network try: import xml.etree.cElementTree as ElementTree @@ -444,9 +443,7 @@ class TVRage: if value: if isinstance(value, dict): if key == 'network': - network = value['#text'] - country = value['@country'] - value = standardize_network(network, country) + value = value['#text'] if key == 'genre': value = value['genre'] if not value: diff --git a/sickbeard/databases/cache_db.py b/sickbeard/databases/cache_db.py index 37f60cf7..815f2660 100644 --- a/sickbeard/databases/cache_db.py +++ b/sickbeard/databases/cache_db.py @@ -88,15 +88,4 @@ class AddSceneExceptionsRefresh(AddSceneExceptionsCustom): def execute(self): self.connection.action( - "CREATE TABLE scene_exceptions_refresh (list TEXT PRIMARY KEY, last_refreshed INTEGER)") - - -class AddNetworkConversions(AddSceneExceptionsRefresh): - def test(self): - return self.hasTable('network_conversions') - - def execute(self): - self.connection.action('CREATE TABLE network_conversions (tvdb_network TEXT PRIMARY KEY, tvrage_network TEXT,' - ' tvrage_country TEXT)') - - self.connection.action('CREATE INDEX tvrage_idx on network_conversions (tvrage_network, tvrage_country)') + "CREATE TABLE scene_exceptions_refresh (list TEXT PRIMARY KEY, last_refreshed INTEGER)") \ No newline at end of file diff --git a/sickbeard/helpers.py b/sickbeard/helpers.py index 72d53a14..2b92f168 100644 --- a/sickbeard/helpers.py +++ b/sickbeard/helpers.py @@ -1428,10 +1428,5 @@ def get_size(start_path='.'): total_size += ek.ek(os.path.getsize, fp) return total_size - -def build_dict(seq, key): - return dict((d[key], dict(d, index=index)) for (index, d) in enumerate(seq)) - - def remove_article(text=''): return re.sub(r'(?i)/^(?:(?:A(?!\s+to)n?)|The)\s(\w)', r'\1', text) \ No newline at end of file diff --git a/sickbeard/network_timezones.py b/sickbeard/network_timezones.py index acc31a8f..a047fc5a 100644 --- a/sickbeard/network_timezones.py +++ b/sickbeard/network_timezones.py @@ -140,7 +140,6 @@ def _update_zoneinfo(): def update_network_dict(): _remove_old_zoneinfo() _update_zoneinfo() - load_network_conversions() d = {} @@ -279,62 +278,3 @@ def test_timeformat(t): return False else: return True - - -def standardize_network(network, country): - myDB = db.DBConnection('cache.db') - sqlResults = myDB.select('SELECT * FROM network_conversions WHERE tvrage_network = ? and tvrage_country = ?', - [network, country]) - if len(sqlResults) == 1: - return sqlResults[0]['tvdb_network'] - else: - return network - - -def load_network_conversions(): - - conversions = [] - - # network conversions are stored on github pages - url = 'https://raw.githubusercontent.com/prinz23/sg_network_conversions/master/conversions.txt' - - url_data = helpers.getURL(url) - if url_data is None: - # When urlData is None, trouble connecting to github - logger.log(u'Updating network conversions failed, this can happen from time to time. URL: %s' % url, logger.WARNING) - return - - try: - for line in url_data.splitlines(): - (tvdb_network, tvrage_network, tvrage_country) = line.decode('utf-8').strip().rsplit(u'::', 2) - if not (tvdb_network and tvrage_network and tvrage_country): - continue - conversions.append({'tvdb_network': tvdb_network, 'tvrage_network': tvrage_network, 'tvrage_country': tvrage_country}) - except (IOError, OSError): - pass - - my_db = db.DBConnection('cache.db') - - old_d = my_db.select('SELECT * FROM network_conversions') - old_d = helpers.build_dict(old_d, 'tvdb_network') - - # list of sql commands to update the network_conversions table - cl = [] - - for n_w in conversions: - cl.append(['INSERT OR REPLACE INTO network_conversions (tvdb_network, tvrage_network, tvrage_country)' - 'VALUES (?,?,?)', [n_w['tvdb_network'], n_w['tvrage_network'], n_w['tvrage_country']]]) - try: - del old_d[n_w['tvdb_network']] - except: - pass - - # remove deleted records - if len(old_d) > 0: - old_items = list(va for va in old_d) - cl.append(['DELETE FROM network_conversions WHERE tvdb_network' - ' IN (%s)' % ','.join(['?'] * len(old_items)), old_items]) - - # change all network conversion info at once (much faster) - if len(cl) > 0: - my_db.mass_action(cl) \ No newline at end of file