Merge branch 'refs/heads/master' into desktop
This commit is contained in:
@@ -3,10 +3,11 @@ import os
|
||||
import time
|
||||
import traceback
|
||||
|
||||
from CodernityDB.database import RecordNotFound
|
||||
from CodernityDB.index import IndexException, IndexNotFoundException, IndexConflict
|
||||
from couchpotato import CPLog
|
||||
from couchpotato.api import addApiView
|
||||
from couchpotato.core.event import addEvent, fireEvent
|
||||
from couchpotato.core.event import addEvent, fireEvent, fireEventAsync
|
||||
from couchpotato.core.helpers.encoding import toUnicode, sp
|
||||
from couchpotato.core.helpers.variable import getImdb, tryInt
|
||||
|
||||
@@ -226,6 +227,33 @@ class Database(object):
|
||||
from couchpotato import Env
|
||||
|
||||
db = self.getDB()
|
||||
|
||||
# Try fix for migration failures on desktop
|
||||
if Env.get('desktop'):
|
||||
try:
|
||||
list(db.all('profile', with_doc = True))
|
||||
except RecordNotFound:
|
||||
|
||||
failed_location = '%s_failed' % db.path
|
||||
old_db = os.path.join(Env.get('data_dir'), 'couchpotato.db.old')
|
||||
|
||||
if not os.path.isdir(failed_location) and os.path.isfile(old_db):
|
||||
db.close()
|
||||
|
||||
# Rename database folder
|
||||
os.rename(db.path, '%s_failed' % db.path)
|
||||
|
||||
# Rename .old database to try another migrate
|
||||
os.rename(old_db, old_db[:-4])
|
||||
|
||||
fireEventAsync('app.restart')
|
||||
else:
|
||||
log.error('Migration failed and couldn\'t recover database. Please report on GitHub, with this message.')
|
||||
db.reindex()
|
||||
|
||||
return
|
||||
|
||||
# Check size and compact if needed
|
||||
size = db.get_db_details().get('size')
|
||||
prop_name = 'last_db_compact'
|
||||
last_check = int(Env.prop(prop_name, default = 0))
|
||||
|
||||
@@ -14,7 +14,7 @@ autoload = 'FanartTV'
|
||||
class FanartTV(MovieProvider):
|
||||
|
||||
urls = {
|
||||
'api': 'http://api.fanart.tv/webservice/movie/b28b14e9be662e027cfbc7c3dd600405/%s/JSON/all/1/2'
|
||||
'api': 'http://webservice.fanart.tv/v3/movies/%s?api_key=b28b14e9be662e027cfbc7c3dd600405'
|
||||
}
|
||||
|
||||
MAX_EXTRAFANART = 20
|
||||
@@ -36,9 +36,8 @@ class FanartTV(MovieProvider):
|
||||
fanart_data = self.getJsonData(url)
|
||||
|
||||
if fanart_data:
|
||||
name, resource = fanart_data.items()[0]
|
||||
log.debug('Found images for %s', name)
|
||||
images = self._parseMovie(resource)
|
||||
log.debug('Found images for %s', fanart_data.get('name'))
|
||||
images = self._parseMovie(fanart_data)
|
||||
|
||||
except:
|
||||
log.error('Failed getting extra art for %s: %s',
|
||||
@@ -95,7 +94,7 @@ class FanartTV(MovieProvider):
|
||||
for image in images:
|
||||
if tryInt(image.get('likes')) > highscore:
|
||||
highscore = tryInt(image.get('likes'))
|
||||
image_url = image.get('url')
|
||||
image_url = image.get('url') or image.get('href')
|
||||
|
||||
return image_url
|
||||
|
||||
@@ -118,7 +117,9 @@ class FanartTV(MovieProvider):
|
||||
if tryInt(image.get('likes')) > highscore:
|
||||
highscore = tryInt(image.get('likes'))
|
||||
best = image
|
||||
image_urls.append(best.get('url'))
|
||||
url = best.get('url') or best.get('href')
|
||||
if url:
|
||||
image_urls.append(url)
|
||||
pool.remove(best)
|
||||
|
||||
return image_urls
|
||||
|
||||
@@ -87,6 +87,13 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En
|
||||
|
||||
# Do db stuff
|
||||
db_path = sp(os.path.join(data_dir, 'database'))
|
||||
old_db_path = os.path.join(data_dir, 'couchpotato.db')
|
||||
|
||||
# Remove database folder if both exists
|
||||
if os.path.isdir(db_path) and os.path.isfile(old_db_path):
|
||||
db = SuperThreadSafeDatabase(db_path)
|
||||
db.open()
|
||||
db.destroy()
|
||||
|
||||
# Check if database exists
|
||||
db = SuperThreadSafeDatabase(db_path)
|
||||
|
||||
Reference in New Issue
Block a user