Merge branch 'refs/heads/develop' into redesign
This commit is contained in:
@@ -4,7 +4,7 @@ import time
|
|||||||
import traceback
|
import traceback
|
||||||
from string import ascii_lowercase
|
from string import ascii_lowercase
|
||||||
|
|
||||||
from CodernityDB.database import RecordNotFound
|
from CodernityDB.database import RecordNotFound, RecordDeleted
|
||||||
from couchpotato import tryInt, get_db
|
from couchpotato import tryInt, get_db
|
||||||
from couchpotato.api import addApiView
|
from couchpotato.api import addApiView
|
||||||
from couchpotato.core.event import fireEvent, fireEventAsync, addEvent
|
from couchpotato.core.event import fireEvent, fireEventAsync, addEvent
|
||||||
@@ -146,7 +146,7 @@ class MediaPlugin(MediaBase):
|
|||||||
|
|
||||||
return media
|
return media
|
||||||
|
|
||||||
except RecordNotFound:
|
except (RecordNotFound, RecordDeleted):
|
||||||
log.error('Media with id "%s" not found', media_id)
|
log.error('Media with id "%s" not found', media_id)
|
||||||
except:
|
except:
|
||||||
raise
|
raise
|
||||||
@@ -488,18 +488,21 @@ class MediaPlugin(MediaBase):
|
|||||||
db.update(m)
|
db.update(m)
|
||||||
|
|
||||||
# Tag media as recent
|
# Tag media as recent
|
||||||
self.tag(media_id, 'recent')
|
self.tag(media_id, 'recent', update_edited = True)
|
||||||
|
|
||||||
return m['status']
|
return m['status']
|
||||||
except:
|
except:
|
||||||
log.error('Failed restatus: %s', traceback.format_exc())
|
log.error('Failed restatus: %s', traceback.format_exc())
|
||||||
|
|
||||||
def tag(self, media_id, tag):
|
def tag(self, media_id, tag, update_edited = False):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db = get_db()
|
db = get_db()
|
||||||
m = db.get('id', media_id)
|
m = db.get('id', media_id)
|
||||||
|
|
||||||
|
if update_edited:
|
||||||
|
m['last_edit'] = int(time.time())
|
||||||
|
|
||||||
tags = m.get('tags') or []
|
tags = m.get('tags') or []
|
||||||
if tag not in tags:
|
if tag not in tags:
|
||||||
tags.append(tag)
|
tags.append(tag)
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class Base(TorrentProvider):
|
|||||||
'name': re.sub('[^A-Za-z0-9\-_ \(\).]+', '', '%s (%s) %s' % (name, year, torrent_desc)),
|
'name': re.sub('[^A-Za-z0-9\-_ \(\).]+', '', '%s (%s) %s' % (name, year, torrent_desc)),
|
||||||
'url': self.urls['download'] % (torrent_id, authkey, self.conf('passkey')),
|
'url': self.urls['download'] % (torrent_id, authkey, self.conf('passkey')),
|
||||||
'detail_url': self.urls['detail'] % torrent_id,
|
'detail_url': self.urls['detail'] % torrent_id,
|
||||||
'size': self.parseSize(entry.find('size').get_text()),
|
'size': tryInt(entry.find('size').get_text()) / 1048576,
|
||||||
'seeders': tryInt(entry.find('seeders').get_text()),
|
'seeders': tryInt(entry.find('seeders').get_text()),
|
||||||
'leechers': tryInt(entry.find('leechers').get_text()),
|
'leechers': tryInt(entry.find('leechers').get_text()),
|
||||||
'score': torrentscore
|
'score': torrentscore
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ autoload = 'FanartTV'
|
|||||||
class FanartTV(MovieProvider):
|
class FanartTV(MovieProvider):
|
||||||
|
|
||||||
urls = {
|
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
|
MAX_EXTRAFANART = 20
|
||||||
@@ -36,9 +36,8 @@ class FanartTV(MovieProvider):
|
|||||||
fanart_data = self.getJsonData(url)
|
fanart_data = self.getJsonData(url)
|
||||||
|
|
||||||
if fanart_data:
|
if fanart_data:
|
||||||
name, resource = fanart_data.items()[0]
|
log.debug('Found images for %s', fanart_data.get('name'))
|
||||||
log.debug('Found images for %s', name)
|
images = self._parseMovie(fanart_data)
|
||||||
images = self._parseMovie(resource)
|
|
||||||
|
|
||||||
except:
|
except:
|
||||||
log.error('Failed getting extra art for %s: %s',
|
log.error('Failed getting extra art for %s: %s',
|
||||||
@@ -95,7 +94,7 @@ class FanartTV(MovieProvider):
|
|||||||
for image in images:
|
for image in images:
|
||||||
if tryInt(image.get('likes')) > highscore:
|
if tryInt(image.get('likes')) > highscore:
|
||||||
highscore = tryInt(image.get('likes'))
|
highscore = tryInt(image.get('likes'))
|
||||||
image_url = image.get('url')
|
image_url = image.get('url') or image.get('href')
|
||||||
|
|
||||||
return image_url
|
return image_url
|
||||||
|
|
||||||
@@ -118,7 +117,9 @@ class FanartTV(MovieProvider):
|
|||||||
if tryInt(image.get('likes')) > highscore:
|
if tryInt(image.get('likes')) > highscore:
|
||||||
highscore = tryInt(image.get('likes'))
|
highscore = tryInt(image.get('likes'))
|
||||||
best = image
|
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)
|
pool.remove(best)
|
||||||
|
|
||||||
return image_urls
|
return image_urls
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ class MovieSearcher(SearcherBase, MovieTypeBase):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if total_result_count > 0:
|
if total_result_count > 0:
|
||||||
fireEvent('media.tag', movie['_id'], 'recent', single = True)
|
fireEvent('media.tag', movie['_id'], 'recent', update_edited = True, single = True)
|
||||||
|
|
||||||
if len(too_early_to_search) > 0:
|
if len(too_early_to_search) > 0:
|
||||||
log.info2('Too early to search for %s, %s', (too_early_to_search, default_title))
|
log.info2('Too early to search for %s, %s', (too_early_to_search, default_title))
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ class XBMC(Notification):
|
|||||||
log.debug('Returned from request %s: %s', (host, response))
|
log.debug('Returned from request %s: %s', (host, response))
|
||||||
|
|
||||||
return response
|
return response
|
||||||
except (MaxRetryError, requests.exceptions.Timeout):
|
except (MaxRetryError, requests.exceptions.Timeout, ConnectionError):
|
||||||
log.info2('Couldn\'t send request to XBMC, assuming it\'s turned off')
|
log.info2('Couldn\'t send request to XBMC, assuming it\'s turned off')
|
||||||
return []
|
return []
|
||||||
except:
|
except:
|
||||||
|
|||||||
@@ -522,7 +522,7 @@ class Renamer(Plugin):
|
|||||||
|
|
||||||
# Mark media for dashboard
|
# Mark media for dashboard
|
||||||
if mark_as_recent:
|
if mark_as_recent:
|
||||||
fireEvent('media.tag', group['media'].get('_id'), 'recent', single = True)
|
fireEvent('media.tag', group['media'].get('_id'), 'recent', update_edited = True, single = True)
|
||||||
|
|
||||||
# Remove leftover files
|
# Remove leftover files
|
||||||
if not remove_leftovers: # Don't remove anything
|
if not remove_leftovers: # Don't remove anything
|
||||||
|
|||||||
@@ -553,7 +553,7 @@ class Scanner(Plugin):
|
|||||||
scan_result = []
|
scan_result = []
|
||||||
for p in paths:
|
for p in paths:
|
||||||
if not group['is_dvd']:
|
if not group['is_dvd']:
|
||||||
video = Video.from_path(toUnicode(p))
|
video = Video.from_path(sp(p))
|
||||||
video_result = [(video, video.scan())]
|
video_result = [(video, video.scan())]
|
||||||
scan_result.extend(video_result)
|
scan_result.extend(video_result)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user