1 parent
369f08b00b
commit
4bdd23e36a
13 files changed
+48
-25
No files matched your search
@@ -1,8 +1,11 @@
|
|||||||
|
from couchpotato.core.logger import CPLog
|
||||||
import hashlib
|
import hashlib
|
||||||
import os.path
|
import os.path
|
||||||
import platform
|
import platform
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
log = CPLog(__name__)
|
||||||
|
|
||||||
def getDataDir():
|
def getDataDir():
|
||||||
|
|
||||||
# Windows
|
# Windows
|
||||||
@@ -102,3 +105,15 @@ def natsortKey(s):
|
|||||||
|
|
||||||
def natcmp(a, b):
|
def natcmp(a, b):
|
||||||
return cmp(natsortKey(a), natsortKey(b))
|
return cmp(natsortKey(a), natsortKey(b))
|
||||||
|
|
||||||
|
def getTitle(library_dict):
|
||||||
|
try:
|
||||||
|
try:
|
||||||
|
return library_dict['titles'][0]['title']
|
||||||
|
except:
|
||||||
|
log.error('Could not get title for %s' % library_dict['identifier'])
|
||||||
|
return None
|
||||||
|
except:
|
||||||
|
log.error('Could not get title for library item: %s' % library_dict)
|
||||||
|
return None
|
||||||
|
|
||||||
@@ -437,7 +437,7 @@ class MoviePlugin(Plugin):
|
|||||||
db = get_session()
|
db = get_session()
|
||||||
|
|
||||||
m = db.query(Movie).filter_by(id = movie_id).first()
|
m = db.query(Movie).filter_by(id = movie_id).first()
|
||||||
if not m:
|
if not m or len(m.library.titles) == 0:
|
||||||
log.debug('Can\'t restatus movie, doesn\'t seem to exist.')
|
log.debug('Can\'t restatus movie, doesn\'t seem to exist.')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from couchpotato.api import addApiView
|
|||||||
from couchpotato.core.event import addEvent, fireEvent, fireEventAsync
|
from couchpotato.core.event import addEvent, fireEvent, fireEventAsync
|
||||||
from couchpotato.core.helpers.encoding import toUnicode
|
from couchpotato.core.helpers.encoding import toUnicode
|
||||||
from couchpotato.core.helpers.request import jsonified
|
from couchpotato.core.helpers.request import jsonified
|
||||||
from couchpotato.core.helpers.variable import getExt, mergeDicts
|
from couchpotato.core.helpers.variable import getExt, mergeDicts, getTitle
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.plugins.base import Plugin
|
from couchpotato.core.plugins.base import Plugin
|
||||||
from couchpotato.core.settings.model import Library, File, Profile
|
from couchpotato.core.settings.model import Library, File, Profile
|
||||||
@@ -82,8 +82,10 @@ class Renamer(Plugin):
|
|||||||
remove_files = []
|
remove_files = []
|
||||||
remove_releases = []
|
remove_releases = []
|
||||||
|
|
||||||
|
movie_title = getTitle(group['library'])
|
||||||
|
|
||||||
# Add _UNKNOWN_ if no library item is connected
|
# Add _UNKNOWN_ if no library item is connected
|
||||||
if not group['library']:
|
if not group['library'] or not movie_title:
|
||||||
if group['dirname']:
|
if group['dirname']:
|
||||||
rename_files[group['parentdir']] = group['parentdir'].replace(group['dirname'], '_UNKNOWN_%s' % group['dirname'])
|
rename_files[group['parentdir']] = group['parentdir'].replace(group['dirname'], '_UNKNOWN_%s' % group['dirname'])
|
||||||
else: # Add it to filename
|
else: # Add it to filename
|
||||||
@@ -105,7 +107,7 @@ class Renamer(Plugin):
|
|||||||
fireEvent('renamer.before', group)
|
fireEvent('renamer.before', group)
|
||||||
|
|
||||||
# Remove weird chars from moviename
|
# Remove weird chars from moviename
|
||||||
movie_name = re.sub(r"[\x00\/\\:\*\?\"<>\|]", '', group['library']['titles'][0]['title'])
|
movie_name = re.sub(r"[\x00\/\\:\*\?\"<>\|]", '', movie_title)
|
||||||
|
|
||||||
# Put 'The' at the end
|
# Put 'The' at the end
|
||||||
name_the = movie_name
|
name_the = movie_name
|
||||||
@@ -369,7 +371,7 @@ class Renamer(Plugin):
|
|||||||
fireEventAsync('renamer.after', group)
|
fireEventAsync('renamer.after', group)
|
||||||
|
|
||||||
# Notify on download
|
# Notify on download
|
||||||
download_message = 'Downloaded %s (%s)' % (group['library']['titles'][0]['title'], replacements['quality'])
|
download_message = 'Downloaded %s (%s)' % (movie_title, replacements['quality'])
|
||||||
fireEventAsync('movie.downloaded', message = download_message, data = group)
|
fireEventAsync('movie.downloaded', message = download_message, data = group)
|
||||||
|
|
||||||
# Break if CP wants to shut down
|
# Break if CP wants to shut down
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from couchpotato.core.event import addEvent
|
from couchpotato.core.event import addEvent
|
||||||
from couchpotato.core.helpers.encoding import toUnicode
|
from couchpotato.core.helpers.encoding import toUnicode
|
||||||
|
from couchpotato.core.helpers.variable import getTitle
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.plugins.base import Plugin
|
from couchpotato.core.plugins.base import Plugin
|
||||||
from couchpotato.core.plugins.score.scores import nameScore, nameRatioScore, \
|
from couchpotato.core.plugins.score.scores import nameScore, nameRatioScore, \
|
||||||
@@ -35,6 +36,6 @@ class Score(Plugin):
|
|||||||
score += providerScore(nzb['provider'])
|
score += providerScore(nzb['provider'])
|
||||||
|
|
||||||
# Duplicates in name
|
# Duplicates in name
|
||||||
score += duplicateScore(nzb['name'], movie['library']['titles'][0]['title'])
|
score += duplicateScore(nzb['name'], getTitle(movie['library']))
|
||||||
|
|
||||||
return score
|
return score
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
from couchpotato import get_session
|
from couchpotato import get_session
|
||||||
from couchpotato.core.event import addEvent, fireEvent
|
from couchpotato.core.event import addEvent, fireEvent
|
||||||
from couchpotato.core.helpers.encoding import simplifyString, toUnicode
|
from couchpotato.core.helpers.encoding import simplifyString, toUnicode
|
||||||
from couchpotato.core.helpers.variable import md5, getImdb
|
from couchpotato.core.helpers.variable import md5, getImdb, getTitle
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.plugins.base import Plugin
|
from couchpotato.core.plugins.base import Plugin
|
||||||
from couchpotato.core.settings.model import Movie, Release, ReleaseInfo
|
from couchpotato.core.settings.model import Movie, Release, ReleaseInfo
|
||||||
@@ -78,7 +78,10 @@ class Searcher(Plugin):
|
|||||||
release_dates = fireEvent('library.update_release_date', identifier = movie['library']['identifier'], merge = True)
|
release_dates = fireEvent('library.update_release_date', identifier = movie['library']['identifier'], merge = True)
|
||||||
available_status = fireEvent('status.get', 'available', single = True)
|
available_status = fireEvent('status.get', 'available', single = True)
|
||||||
|
|
||||||
default_title = movie['library']['titles'][0]['title']
|
default_title = getTitle(movie['library'])
|
||||||
|
if not default_title:
|
||||||
|
return
|
||||||
|
|
||||||
for quality_type in movie['profile']['types']:
|
for quality_type in movie['profile']['types']:
|
||||||
if not self.couldBeReleased(quality_type['quality']['identifier'], release_dates, pre_releases):
|
if not self.couldBeReleased(quality_type['quality']['identifier'], release_dates, pre_releases):
|
||||||
log.info('To early to search for %s, %s' % (quality_type['quality']['identifier'], default_title))
|
log.info('To early to search for %s, %s' % (quality_type['quality']['identifier'], default_title))
|
||||||
@@ -168,7 +171,7 @@ class Searcher(Plugin):
|
|||||||
rls.status_id = snatched_status.get('id')
|
rls.status_id = snatched_status.get('id')
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
log_movie = '%s (%s) in %s' % (movie['library']['titles'][0]['title'], movie['library']['year'], rls.quality.label)
|
log_movie = '%s (%s) in %s' % (getTitle(movie['library']), movie['library']['year'], rls.quality.label)
|
||||||
snatch_message = 'Snatched "%s": %s' % (data.get('name'), log_movie)
|
snatch_message = 'Snatched "%s": %s' % (data.get('name'), log_movie)
|
||||||
log.info(snatch_message)
|
log.info(snatch_message)
|
||||||
fireEvent('movie.snatched', message = snatch_message, data = rls.to_dict())
|
fireEvent('movie.snatched', message = snatch_message, data = rls.to_dict())
|
||||||
@@ -274,7 +277,7 @@ class Searcher(Plugin):
|
|||||||
if self.checkNFO(nzb['name'], movie['library']['identifier']):
|
if self.checkNFO(nzb['name'], movie['library']['identifier']):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
log.info("Wrong: %s, undetermined naming. Looking for '%s (%s)'" % (nzb['name'], movie['library']['titles'][0]['title'], movie['library']['year']))
|
log.info("Wrong: %s, undetermined naming. Looking for '%s (%s)'" % (nzb['name'], getTitle(movie['library']), movie['library']['year']))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def containsOtherQuality(self, nzb, movie_year = None, preferred_quality = {}, single_category = False):
|
def containsOtherQuality(self, nzb, movie_year = None, preferred_quality = {}, single_category = False):
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from couchpotato.core.helpers.encoding import toUnicode
|
from couchpotato.core.helpers.encoding import toUnicode
|
||||||
|
from couchpotato.core.helpers.variable import getTitle
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.providers.metadata.base import MetaDataBase
|
from couchpotato.core.providers.metadata.base import MetaDataBase
|
||||||
from xml.etree.ElementTree import Element, SubElement, tostring
|
from xml.etree.ElementTree import Element, SubElement, tostring
|
||||||
@@ -32,7 +33,7 @@ class XBMC(MetaDataBase):
|
|||||||
# Title
|
# Title
|
||||||
try:
|
try:
|
||||||
el = SubElement(nfoxml, 'title')
|
el = SubElement(nfoxml, 'title')
|
||||||
el.text = toUnicode(data['library']['titles'][0]['title'])
|
el.text = toUnicode(getTitle(data['library']))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from couchpotato.core.event import fireEvent
|
from couchpotato.core.event import fireEvent
|
||||||
from couchpotato.core.helpers.encoding import tryUrlencode
|
from couchpotato.core.helpers.encoding import tryUrlencode
|
||||||
|
from couchpotato.core.helpers.variable import getTitle
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.providers.nzb.base import NZBProvider
|
from couchpotato.core.providers.nzb.base import NZBProvider
|
||||||
from dateutil.parser import parse
|
from dateutil.parser import parse
|
||||||
@@ -26,7 +27,7 @@ class Moovee(NZBProvider):
|
|||||||
if self.isDisabled() or not self.isAvailable(self.urls['search']) or quality.get('hd', False):
|
if self.isDisabled() or not self.isAvailable(self.urls['search']) or quality.get('hd', False):
|
||||||
return results
|
return results
|
||||||
|
|
||||||
q = '%s %s' % (movie['library']['titles'][0]['title'], quality.get('identifier'))
|
q = '%s %s' % (getTitle(movie['library']), quality.get('identifier'))
|
||||||
url = self.urls['search'] % tryUrlencode(q)
|
url = self.urls['search'] % tryUrlencode(q)
|
||||||
|
|
||||||
cache_key = 'moovee.%s' % q
|
cache_key = 'moovee.%s' % q
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from BeautifulSoup import BeautifulSoup
|
from BeautifulSoup import BeautifulSoup
|
||||||
from couchpotato.core.event import fireEvent
|
from couchpotato.core.event import fireEvent
|
||||||
from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode
|
from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode
|
||||||
from couchpotato.core.helpers.variable import tryInt
|
from couchpotato.core.helpers.variable import tryInt, getTitle
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.providers.nzb.base import NZBProvider
|
from couchpotato.core.providers.nzb.base import NZBProvider
|
||||||
from couchpotato.environment import Env
|
from couchpotato.environment import Env
|
||||||
@@ -25,7 +25,7 @@ class Mysterbin(NZBProvider):
|
|||||||
if self.isDisabled() or not self.isAvailable(self.urls['search']):
|
if self.isDisabled() or not self.isAvailable(self.urls['search']):
|
||||||
return results
|
return results
|
||||||
|
|
||||||
q = '"%s" %s %s' % (movie['library']['titles'][0]['title'], movie['library']['year'], quality.get('identifier'))
|
q = '"%s" %s %s' % (getTitle(movie['library']), movie['library']['year'], quality.get('identifier'))
|
||||||
for ignored in Env.setting('ignored_words', 'searcher').split(','):
|
for ignored in Env.setting('ignored_words', 'searcher').split(','):
|
||||||
q = '%s -%s' % (q, ignored.strip())
|
q = '%s -%s' % (q, ignored.strip())
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ from BeautifulSoup import BeautifulSoup
|
|||||||
from couchpotato.core.event import fireEvent
|
from couchpotato.core.event import fireEvent
|
||||||
from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode
|
from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode
|
||||||
from couchpotato.core.helpers.rss import RSS
|
from couchpotato.core.helpers.rss import RSS
|
||||||
from couchpotato.core.helpers.variable import tryInt
|
from couchpotato.core.helpers.variable import tryInt, getTitle
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.providers.nzb.base import NZBProvider
|
from couchpotato.core.providers.nzb.base import NZBProvider
|
||||||
from couchpotato.environment import Env
|
from couchpotato.environment import Env
|
||||||
@@ -27,7 +27,7 @@ class NZBClub(NZBProvider, RSS):
|
|||||||
if self.isDisabled() or not self.isAvailable(self.urls['search']):
|
if self.isDisabled() or not self.isAvailable(self.urls['search']):
|
||||||
return results
|
return results
|
||||||
|
|
||||||
q = '"%s" %s %s' % (movie['library']['titles'][0]['title'], movie['library']['year'], quality.get('identifier'))
|
q = '"%s" %s %s' % (getTitle(movie['library']), movie['library']['year'], quality.get('identifier'))
|
||||||
for ignored in Env.setting('ignored_words', 'searcher').split(','):
|
for ignored in Env.setting('ignored_words', 'searcher').split(','):
|
||||||
q = '%s -%s' % (q, ignored.strip())
|
q = '%s -%s' % (q, ignored.strip())
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ from BeautifulSoup import BeautifulSoup
|
|||||||
from couchpotato.core.event import fireEvent
|
from couchpotato.core.event import fireEvent
|
||||||
from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode
|
from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode
|
||||||
from couchpotato.core.helpers.rss import RSS
|
from couchpotato.core.helpers.rss import RSS
|
||||||
from couchpotato.core.helpers.variable import tryInt
|
from couchpotato.core.helpers.variable import tryInt, getTitle
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.providers.nzb.base import NZBProvider
|
from couchpotato.core.providers.nzb.base import NZBProvider
|
||||||
from couchpotato.environment import Env
|
from couchpotato.environment import Env
|
||||||
@@ -29,7 +29,7 @@ class NzbIndex(NZBProvider, RSS):
|
|||||||
if self.isDisabled() or not self.isAvailable(self.urls['api']):
|
if self.isDisabled() or not self.isAvailable(self.urls['api']):
|
||||||
return results
|
return results
|
||||||
|
|
||||||
q = '%s %s %s' % (movie['library']['titles'][0]['title'], movie['library']['year'], quality.get('identifier'))
|
q = '%s %s %s' % (getTitle(movie['library']), movie['library']['year'], quality.get('identifier'))
|
||||||
arguments = tryUrlencode({
|
arguments = tryUrlencode({
|
||||||
'q': q,
|
'q': q,
|
||||||
'age': Env.setting('retention', 'nzb'),
|
'age': Env.setting('retention', 'nzb'),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from couchpotato.core.event import fireEvent
|
from couchpotato.core.event import fireEvent
|
||||||
from couchpotato.core.helpers.encoding import tryUrlencode
|
from couchpotato.core.helpers.encoding import tryUrlencode
|
||||||
from couchpotato.core.helpers.variable import tryInt
|
from couchpotato.core.helpers.variable import tryInt, getTitle
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.providers.nzb.base import NZBProvider
|
from couchpotato.core.providers.nzb.base import NZBProvider
|
||||||
import re
|
import re
|
||||||
@@ -25,7 +25,7 @@ class X264(NZBProvider):
|
|||||||
if self.isDisabled() or not self.isAvailable(self.urls['search'].split('requests')[0]) or not quality.get('hd', False):
|
if self.isDisabled() or not self.isAvailable(self.urls['search'].split('requests')[0]) or not quality.get('hd', False):
|
||||||
return results
|
return results
|
||||||
|
|
||||||
q = '%s %s %s' % (movie['library']['titles'][0]['title'], movie['library']['year'], quality.get('identifier'))
|
q = '%s %s %s' % (getTitle(movie['library']), movie['library']['year'], quality.get('identifier'))
|
||||||
url = self.urls['search'] % tryUrlencode(q)
|
url = self.urls['search'] % tryUrlencode(q)
|
||||||
|
|
||||||
cache_key = 'x264.%s.%s' % (movie['library']['identifier'], quality.get('identifier'))
|
cache_key = 'x264.%s.%s' % (movie['library']['identifier'], quality.get('identifier'))
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from BeautifulSoup import BeautifulSoup
|
from BeautifulSoup import BeautifulSoup
|
||||||
from couchpotato.core.event import fireEvent
|
from couchpotato.core.event import fireEvent
|
||||||
from couchpotato.core.helpers.variable import tryInt
|
from couchpotato.core.helpers.variable import tryInt, getTitle
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.providers.torrent.base import TorrentProvider
|
from couchpotato.core.providers.torrent.base import TorrentProvider
|
||||||
import StringIO
|
import StringIO
|
||||||
@@ -38,7 +38,7 @@ class KickAssTorrents(TorrentProvider):
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
cache_key = 'kickasstorrents.%s.%s' % (movie['library']['identifier'], quality.get('identifier'))
|
cache_key = 'kickasstorrents.%s.%s' % (movie['library']['identifier'], quality.get('identifier'))
|
||||||
data = self.getCache(cache_key, self.urls['search'] % (movie['library']['titles'][0]['title'], movie['library']['identifier'].replace('tt', '')))
|
data = self.getCache(cache_key, self.urls['search'] % (getTitle(movie['library']), movie['library']['identifier'].replace('tt', '')))
|
||||||
if data:
|
if data:
|
||||||
|
|
||||||
cat_ids = self.getCatId(quality['identifier'])
|
cat_ids = self.getCatId(quality['identifier'])
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from BeautifulSoup import SoupStrainer, BeautifulSoup
|
from BeautifulSoup import SoupStrainer, BeautifulSoup
|
||||||
from couchpotato.core.helpers.encoding import tryUrlencode
|
from couchpotato.core.helpers.encoding import tryUrlencode
|
||||||
from couchpotato.core.helpers.variable import mergeDicts
|
from couchpotato.core.helpers.variable import mergeDicts, getTitle
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.providers.trailer.base import TrailerProvider
|
from couchpotato.core.providers.trailer.base import TrailerProvider
|
||||||
from string import letters, digits
|
from string import letters, digits
|
||||||
@@ -19,7 +19,7 @@ class HDTrailers(TrailerProvider):
|
|||||||
|
|
||||||
def search(self, group):
|
def search(self, group):
|
||||||
|
|
||||||
movie_name = group['library']['titles'][0]['title']
|
movie_name = getTitle(group['library'])
|
||||||
|
|
||||||
url = self.urls['api'] % self.movieUrlName(movie_name)
|
url = self.urls['api'] % self.movieUrlName(movie_name)
|
||||||
data = self.getCache('hdtrailers.%s' % group['library']['identifier'], url)
|
data = self.getCache('hdtrailers.%s' % group['library']['identifier'], url)
|
||||||
@@ -44,7 +44,7 @@ class HDTrailers(TrailerProvider):
|
|||||||
def findViaAlternative(self, group):
|
def findViaAlternative(self, group):
|
||||||
results = {'480p':[], '720p':[], '1080p':[]}
|
results = {'480p':[], '720p':[], '1080p':[]}
|
||||||
|
|
||||||
movie_name = group['library']['titles'][0]['title']
|
movie_name = getTitle(group['library'])
|
||||||
|
|
||||||
url = "%s?%s" % (self.url['backup'], tryUrlencode({'s':movie_name}))
|
url = "%s?%s" % (self.url['backup'], tryUrlencode({'s':movie_name}))
|
||||||
data = self.getCache('hdtrailers.alt.%s' % group['library']['identifier'], url)
|
data = self.getCache('hdtrailers.alt.%s' % group['library']['identifier'], url)
|
||||||
|
|||||||
Reference in new issue
Block a user