Merge branch 'refs/heads/develop'

This commit is contained in:
Ruud committed 2012-09-24 09:36:59 +02:00
commit 9312336962
27 files changed
+71 -59

No files matched your search

+1 -1
View File
@@ -56,7 +56,7 @@ class Downloader(Plugin):
return is_correct return is_correct
def magnetToTorrent(self, magnet_link): def magnetToTorrent(self, magnet_link):
torrent_hash = re.findall('urn:btih:([\w]{32,40})', magnet_link)[0] torrent_hash = re.findall('urn:btih:([\w]{32,40})', magnet_link)[0].upper()
# Convert base 32 to hex # Convert base 32 to hex
if len(torrent_hash) == 32: if len(torrent_hash) == 32:
+46 -39
View File
@@ -2,8 +2,8 @@ from couchpotato.core.downloaders.base import Downloader
from couchpotato.core.helpers.encoding import tryUrlencode from couchpotato.core.helpers.encoding import tryUrlencode
from couchpotato.core.helpers.variable import cleanHost from couchpotato.core.helpers.variable import cleanHost
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
import traceback
import json import json
import traceback
log = CPLog(__name__) log = CPLog(__name__)
@@ -91,15 +91,19 @@ class Sabnzbd(Downloader):
log.error('Failed parsing json status: %s', traceback.format_exc()) log.error('Failed parsing json status: %s', traceback.format_exc())
return False return False
for slot in history['queue']['slots']: try:
log.debug('Found %s in SabNZBd queue, which is %s, with %s left', (slot['filename'], slot['status'], slot['timeleft'])) for slot in history['queue']['slots']:
if slot['filename'] == nzbname: log.debug('Found %s in SabNZBd queue, which is %s, with %s left', (slot['filename'], slot['status'], slot['timeleft']))
return slot['status'].lower() if slot['filename'] == nzbname:
return slot['status'].lower()
except:
log.debug('No items in queue: %s', (traceback.format_exc()))
# Go through history items # Go through history items
params = { params = {
'apikey': self.conf('api_key'), 'apikey': self.conf('api_key'),
'mode': 'history', 'mode': 'history',
'limit': 15,
'output': 'json' 'output': 'json'
} }
url = cleanHost(self.conf('host')) + "api?" + tryUrlencode(params) url = cleanHost(self.conf('host')) + "api?" + tryUrlencode(params)
@@ -117,45 +121,48 @@ class Sabnzbd(Downloader):
log.error('Failed parsing history json: %s', traceback.format_exc()) log.error('Failed parsing history json: %s', traceback.format_exc())
return return
for slot in history['history']['slots']: try:
log.debug('Found %s in SabNZBd history, which has %s', (slot['name'], slot['status'])) for slot in history['history']['slots']:
if slot['name'] == nzbname: log.debug('Found %s in SabNZBd history, which has %s', (slot['name'], slot['status']))
# Note: if post process even if failed is on in SabNZBd, it will complete with a fail message if slot['name'] == nzbname:
if slot['status'] == 'Failed' or (slot['status'] == 'Completed' and slot['fail_message'].strip()): # Note: if post process even if failed is on in SabNZBd, it will complete with a fail message
if slot['status'] == 'Failed' or (slot['status'] == 'Completed' and slot['fail_message'].strip()):
# Delete failed download # Delete failed download
if self.conf('delete_failed', default = True): if self.conf('delete_failed', default = True):
log.info('%s failed downloading, deleting...', slot['name']) log.info('%s failed downloading, deleting...', slot['name'])
params = { params = {
'apikey': self.conf('api_key'), 'apikey': self.conf('api_key'),
'mode': 'history', 'mode': 'history',
'name': 'delete', 'name': 'delete',
'del_files': '1', 'del_files': '1',
'value': slot['nzo_id'] 'value': slot['nzo_id']
} }
url = cleanHost(self.conf('host')) + "api?" + tryUrlencode(params) url = cleanHost(self.conf('host')) + "api?" + tryUrlencode(params)
try: try:
sab = self.urlopen(url, timeout = 60, show_error = False) sab = self.urlopen(url, timeout = 60, show_error = False)
except: except:
log.error('Failed deleting: %s', traceback.format_exc()) log.error('Failed deleting: %s', traceback.format_exc())
return False return False
result = sab.strip() result = sab.strip()
if not result: if not result:
log.error("SABnzbd didn't return anything.") log.error("SABnzbd didn't return anything.")
log.debug("Result text from SAB: " + result[:40]) log.debug("Result text from SAB: " + result[:40])
if result == "ok": if result == "ok":
log.info('SabNZBd deleted failed release %s successfully.', slot['name']) log.info('SabNZBd deleted failed release %s successfully.', slot['name'])
elif result == "Missing authentication": elif result == "Missing authentication":
log.error("Incorrect username/password or API?.") log.error("Incorrect username/password or API?.")
else: else:
log.error("Unknown error: " + result[:40]) log.error("Unknown error: " + result[:40])
return 'failed' return 'failed'
else: else:
return slot['status'].lower() return slot['status'].lower()
except:
log.debug('No items in history: %s', (traceback.format_exc()))
return 'not_found' return 'not_found'
@@ -2,6 +2,7 @@ from couchpotato.core.event import addEvent
from couchpotato.core.helpers.request import jsonified from couchpotato.core.helpers.request import jsonified
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification from couchpotato.core.notifications.base import Notification
import os
import subprocess import subprocess
log = CPLog(__name__) log = CPLog(__name__)
@@ -9,6 +10,8 @@ log = CPLog(__name__)
class Synoindex(Notification): class Synoindex(Notification):
index_path = '/usr/syno/bin/synoindex'
def __init__(self): def __init__(self):
super(Synoindex, self).__init__() super(Synoindex, self).__init__()
addEvent('renamer.after', self.addToLibrary) addEvent('renamer.after', self.addToLibrary)
@@ -16,7 +19,7 @@ class Synoindex(Notification):
def addToLibrary(self, group = {}): def addToLibrary(self, group = {}):
if self.isDisabled(): return if self.isDisabled(): return
command = ['/usr/syno/bin/synoindex', '-A', group.get('destination_dir', '')] command = [self.index_path, '-A', group.get('destination_dir')]
log.info('Executing synoindex command: %s ', command) log.info('Executing synoindex command: %s ', command)
try: try:
p = subprocess.Popen(command, stdout = subprocess.PIPE, stderr = subprocess.STDOUT) p = subprocess.Popen(command, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
@@ -30,5 +33,4 @@ class Synoindex(Notification):
return True return True
def test(self): def test(self):
success = self.addToLibrary() return jsonified({'success': os.path.isfile(self.index_path)})
return jsonified({'success': success})
+6 -8
View File
@@ -1,6 +1,7 @@
from couchpotato import get_session from couchpotato import get_session
from couchpotato.core.event import addEvent, fireEventAsync, fireEvent from couchpotato.core.event import addEvent, fireEventAsync, fireEvent
from couchpotato.core.helpers.encoding import toUnicode, simplifyString from couchpotato.core.helpers.encoding import toUnicode, simplifyString
from couchpotato.core.helpers.variable import mergeDicts
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, LibraryTitle, File from couchpotato.core.settings.model import Library, LibraryTitle, File
@@ -138,26 +139,23 @@ class LibraryPlugin(Plugin):
library = db.query(Library).filter_by(identifier = identifier).first() library = db.query(Library).filter_by(identifier = identifier).first()
if not library.info: if not library.info:
library_dict = self.update(identifier) library_dict = self.update(identifier, force = True)
dates = library_dict.get('info', {}).get('release_dates') dates = library_dict.get('info', {}).get('release_date')
else: else:
dates = library.info.get('release_date') dates = library.info.get('release_date')
if dates and dates.get('expires', 0) < time.time(): if dates and dates.get('expires', 0) < time.time() or not dates:
dates = fireEvent('movie.release_date', identifier = identifier, merge = True) dates = fireEvent('movie.release_date', identifier = identifier, merge = True)
library.info['release_date'] = dates library.info = mergeDicts(library.info, {'release_date': dates })
library.info = library.info
db.commit() db.commit()
dates = library.info.get('release_date', {})
#db.close()
return dates return dates
def simplifyTitle(self, title): def simplifyTitle(self, title):
title = toUnicode(title) title = toUnicode(title)
nr_prefix = '' if title[0] in ascii_letters else '#' nr_prefix = '' if title[0] in ascii_letters else '#'
title = simplifyString(title) title = simplifyString(title)
+8 -5
View File
@@ -320,17 +320,20 @@ class Scanner(Plugin):
# Only process movies newer than x # Only process movies newer than x
if newer_than and newer_than > 0: if newer_than and newer_than > 0:
has_new_files = False
for cur_file in group['unsorted_files']: for cur_file in group['unsorted_files']:
file_time = [os.path.getmtime(cur_file), os.path.getctime(cur_file)] file_time = [os.path.getmtime(cur_file), os.path.getctime(cur_file)]
if file_time[0] > time.time() or file_time[1] > time.time(): if file_time[0] > newer_than or file_time[1] > newer_than:
has_new_files = True
break break
log.debug('None of the files have changed since %s for %s, skipping.', (time.ctime(newer_than), identifier)) if not has_new_files:
log.debug('None of the files have changed since %s for %s, skipping.', (time.ctime(newer_than), identifier))
# Delete the unsorted list # Delete the unsorted list
del group['unsorted_files'] del group['unsorted_files']
continue continue
# Group extra (and easy) files first # Group extra (and easy) files first
# images = self.getImages(group['unsorted_files']) # images = self.getImages(group['unsorted_files'])
@@ -6,6 +6,7 @@ from couchpotato.core.logger import CPLog
from couchpotato.core.providers.movie.base import MovieProvider from couchpotato.core.providers.movie.base import MovieProvider
from couchpotato.core.settings.model import Movie from couchpotato.core.settings.model import Movie
from flask.helpers import json from flask.helpers import json
import time
import traceback import traceback
log = CPLog(__name__) log = CPLog(__name__)
@@ -13,11 +14,11 @@ log = CPLog(__name__)
class CouchPotatoApi(MovieProvider): class CouchPotatoApi(MovieProvider):
api_url = 'http://couchpota.to/api/%s/'
urls = { urls = {
'search': 'https://couchpota.to/api/search/%s/', 'search': 'https://couchpota.to/api/search/%s/',
'info': 'https://couchpota.to/api/info/%s/', 'info': 'https://couchpota.to/api/info/%s/',
'eta': 'https://couchpota.to/api/eta/%s/', 'eta': 'https://couchpota.to/api/eta/%s/',
'suggest': 'https://couchpota.to/api/suggest/%s/%s/',
} }
http_time_between_calls = 0 http_time_between_calls = 0
api_version = 1 api_version = 1
@@ -64,7 +65,7 @@ class CouchPotatoApi(MovieProvider):
if identifier is None: return {} if identifier is None: return {}
try: try:
data = self.urlopen((self.api_url % ('eta')) + (identifier + '/'), headers = self.getRequestHeaders()) data = self.urlopen(self.urls['eta'] % identifier, headers = self.getRequestHeaders())
dates = json.loads(data) dates = json.loads(data)
log.debug('Found ETA for %s: %s', (identifier, dates)) log.debug('Found ETA for %s: %s', (identifier, dates))
return dates return dates
@@ -75,7 +76,7 @@ class CouchPotatoApi(MovieProvider):
def suggest(self, movies = [], ignore = []): def suggest(self, movies = [], ignore = []):
try: try:
data = self.urlopen((self.api_url % ('suggest')) + ','.join(movies) + '/' + ','.join(ignore) + '/') data = self.urlopen(self.urls['suggest'] % (','.join(movies), ','.join(ignore)))
suggestions = json.loads(data) suggestions = json.loads(data)
log.info('Found Suggestions for %s', (suggestions)) log.info('Found Suggestions for %s', (suggestions))
except Exception, e: except Exception, e:
@@ -107,4 +108,5 @@ class CouchPotatoApi(MovieProvider):
return { return {
'X-CP-Version': fireEvent('app.version', single = True), 'X-CP-Version': fireEvent('app.version', single = True),
'X-CP-API': self.api_version, 'X-CP-API': self.api_version,
'X-CP-Time': time.time(),
} }
Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 573 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 451 B

After

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 228 B

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 502 B

After

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 624 B

After

Width:  |  Height:  |  Size: 511 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 840 B

After

Width:  |  Height:  |  Size: 763 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 757 B

After

Width:  |  Height:  |  Size: 690 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 B

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 778 B

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 B

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 674 B

After

Width:  |  Height:  |  Size: 568 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 596 B

After

Width:  |  Height:  |  Size: 435 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 587 B

After

Width:  |  Height:  |  Size: 585 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 223 B

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 838 B

After

Width:  |  Height:  |  Size: 56 B