mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-08 11:03:38 +00:00
Fix load web dl types from db if url fetching fails.
This commit is contained in:
parent
233739a58c
commit
dca5bc6856
1 changed files with 8 additions and 4 deletions
|
@ -142,7 +142,12 @@ def load_webdl_types():
|
||||||
default_types = [('Amazon', r'AMZN|AMAZON'), ('Netflix', r'NETFLIX|NF'), ('Hulu', r'HULU')]
|
default_types = [('Amazon', r'AMZN|AMAZON'), ('Netflix', r'NETFLIX|NF'), ('Hulu', r'HULU')]
|
||||||
url = 'https://raw.githubusercontent.com/SickGear/sickgear.extdata/master/SickGear/webdl_types.txt'
|
url = 'https://raw.githubusercontent.com/SickGear/sickgear.extdata/master/SickGear/webdl_types.txt'
|
||||||
url_data = helpers.getURL(url)
|
url_data = helpers.getURL(url)
|
||||||
if url_data:
|
|
||||||
|
my_db = db.DBConnection()
|
||||||
|
sql_results = my_db.select('SELECT * FROM webdl_types')
|
||||||
|
old_types = [(r['dname'], r['regex']) for r in sql_results]
|
||||||
|
|
||||||
|
if isinstance(url_data, basestring) and url_data.strip():
|
||||||
try:
|
try:
|
||||||
for line in url_data.splitlines():
|
for line in url_data.splitlines():
|
||||||
try:
|
try:
|
||||||
|
@ -155,9 +160,6 @@ def load_webdl_types():
|
||||||
except (IOError, OSError):
|
except (IOError, OSError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
my_db = db.DBConnection()
|
|
||||||
sql_results = my_db.select('SELECT * FROM webdl_types')
|
|
||||||
old_types = [(r['dname'], r['regex']) for r in sql_results]
|
|
||||||
cl = []
|
cl = []
|
||||||
for nt in new_types:
|
for nt in new_types:
|
||||||
if nt not in old_types:
|
if nt not in old_types:
|
||||||
|
@ -169,6 +171,8 @@ def load_webdl_types():
|
||||||
|
|
||||||
if cl:
|
if cl:
|
||||||
my_db.mass_action(cl)
|
my_db.mass_action(cl)
|
||||||
|
else:
|
||||||
|
new_types = old_types
|
||||||
|
|
||||||
sickbeard.WEBDL_TYPES = new_types + default_types
|
sickbeard.WEBDL_TYPES = new_types + default_types
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue