Compare commits
97
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
506871b506 | ||
|
|
6115917660 | ||
|
|
44b78f8d2f | ||
|
|
21df8819d3 | ||
|
|
cad9bfae9f | ||
|
|
749075b4cb | ||
|
|
0456a1e820 | ||
|
|
35a9739ec5 | ||
|
|
2a451c255e | ||
|
|
7c38ad1c00 | ||
|
|
647159e549 | ||
|
|
7cc55c21b6 | ||
|
|
89c38f5aa4 | ||
|
|
5f428649c3 | ||
|
|
8ed2a99830 | ||
|
|
1a89d551dc | ||
|
|
9d633910f6 | ||
|
|
54ea22e9b6 | ||
|
|
fb3f3e11f6 | ||
|
|
f84b23eecc | ||
|
|
6ea045ddd3 | ||
|
|
f8b4e75b74 | ||
|
|
faaf351662 | ||
|
|
f41fc794c1 | ||
|
|
0f789b5b40 | ||
|
|
d2496d768d | ||
|
|
b93488f025 | ||
|
|
d4de68ef86 | ||
|
|
61a0bb8ec6 | ||
|
|
fe52ac7203 | ||
|
|
4447b7611e | ||
|
|
178c8942c3 | ||
|
|
4fe9f9e42f | ||
|
|
71b22345bc | ||
|
|
a0dc5c075a | ||
|
|
a264c75f8c | ||
|
|
fcc8a71eae | ||
|
|
cdd681ad48 | ||
|
|
36e5c49147 | ||
|
|
300f4738a0 | ||
|
|
9447833653 | ||
|
|
df53d0c578 | ||
|
|
17eaba3e2a | ||
|
|
0f389f18cb | ||
|
|
28ce083f48 | ||
|
|
cfaffe2bcb | ||
|
|
432852cf5d | ||
|
|
3c728608e9 | ||
|
|
8892ace3c2 | ||
|
|
87574a1810 | ||
|
|
14e0219e62 | ||
|
|
51e747049d | ||
|
|
0582f7d694 | ||
|
|
fa7cac7538 | ||
|
|
ec857a9b3d | ||
|
|
4d32b0b16d | ||
|
|
ca08287cff | ||
|
|
36fee69843 | ||
|
|
c5cae5ab9b | ||
|
|
9bd5688fb9 | ||
|
|
1993c2b6cb | ||
|
|
acc8ed2092 | ||
|
|
7b4924dd7a | ||
|
|
3a2861f72a | ||
|
|
4779265b43 | ||
|
|
f8a46ebe6d | ||
|
|
383ec7e6f5 | ||
|
|
dd9118292d | ||
|
|
4d0f8eb4ac | ||
|
|
637b21cc68 | ||
|
|
da429f0cb8 | ||
|
|
41c2845328 | ||
|
|
c2453bb070 | ||
|
|
a3a2c8da8e | ||
|
|
a1d4bab793 | ||
|
|
d314a9b5b3 | ||
|
|
9a60f6001a | ||
|
|
96a39dbf60 | ||
|
|
015675750c | ||
|
|
bf4dc62f54 | ||
|
|
c2382ade05 | ||
|
|
2f65545086 | ||
|
|
3aea2cd968 | ||
|
|
f30cb9185c | ||
|
|
615468e8e6 | ||
|
|
0cbee01024 | ||
|
|
c29cb39797 | ||
|
|
580ff38136 | ||
|
|
6b8bca5491 | ||
|
|
e92b5d95ca | ||
|
|
611a32d110 | ||
|
|
74e4b015a9 | ||
|
|
1e0267cdb5 | ||
|
|
041a206fb4 | ||
|
|
12a4d6a995 | ||
|
|
b14a6c1e63 | ||
|
|
7fa08ef9b6 |
+1
-2
@@ -62,7 +62,6 @@ class Loader(object):
|
|||||||
self.log.logger.addHandler(hdlr)
|
self.log.logger.addHandler(hdlr)
|
||||||
|
|
||||||
def addSignals(self):
|
def addSignals(self):
|
||||||
|
|
||||||
signal.signal(signal.SIGINT, self.onExit)
|
signal.signal(signal.SIGINT, self.onExit)
|
||||||
signal.signal(signal.SIGTERM, lambda signum, stack_frame: sys.exit(1))
|
signal.signal(signal.SIGTERM, lambda signum, stack_frame: sys.exit(1))
|
||||||
|
|
||||||
@@ -74,7 +73,7 @@ class Loader(object):
|
|||||||
|
|
||||||
def onExit(self, signal, frame):
|
def onExit(self, signal, frame):
|
||||||
from couchpotato.core.event import fireEvent
|
from couchpotato.core.event import fireEvent
|
||||||
fireEvent('app.crappy_shutdown', single = True)
|
fireEvent('app.shutdown', single = True)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -5,9 +5,10 @@
|
|||||||
* Search through the existing (and closed) issues first. See if you can get your answer there.
|
* Search through the existing (and closed) issues first. See if you can get your answer there.
|
||||||
* Double check the result manually, because it could be an external issue.
|
* Double check the result manually, because it could be an external issue.
|
||||||
* Post logs! Without seeing what is going on, I can't reproduce the error.
|
* Post logs! Without seeing what is going on, I can't reproduce the error.
|
||||||
* What are you settings for the specific problem
|
* What is the movie + quality you are searching for.
|
||||||
* What providers are you using. (While your logs include these, scanning through hundred of lines of log isn't my hobby)
|
* What are you settings for the specific problem.
|
||||||
* Give me a short step by step of how to reproduce
|
* What providers are you using. (While your logs include these, scanning through hundred of lines of log isn't my hobby).
|
||||||
|
* Give me a short step by step of how to reproduce.
|
||||||
* What hardware / OS are you using and what are the limits? NAS can be slow and maybe have a different python installed then when you use CP on OSX or Windows for example.
|
* What hardware / OS are you using and what are the limits? NAS can be slow and maybe have a different python installed then when you use CP on OSX or Windows for example.
|
||||||
* I will mark issues with the "can't reproduce" tag. Don't go asking me "why closed" if it clearly says the issue in the tag ;)
|
* I will mark issues with the "can't reproduce" tag. Don't go asking me "why closed" if it clearly says the issue in the tag ;)
|
||||||
|
|
||||||
|
|||||||
+5
-2
@@ -1,6 +1,5 @@
|
|||||||
from flask.blueprints import Blueprint
|
from flask.blueprints import Blueprint
|
||||||
from flask.helpers import url_for
|
from flask.helpers import url_for
|
||||||
from tornado.ioloop import IOLoop
|
|
||||||
from tornado.web import RequestHandler, asynchronous
|
from tornado.web import RequestHandler, asynchronous
|
||||||
from werkzeug.utils import redirect
|
from werkzeug.utils import redirect
|
||||||
|
|
||||||
@@ -11,7 +10,11 @@ api_nonblock = {}
|
|||||||
|
|
||||||
|
|
||||||
class NonBlockHandler(RequestHandler):
|
class NonBlockHandler(RequestHandler):
|
||||||
stoppers = []
|
|
||||||
|
def __init__(self, application, request, **kwargs):
|
||||||
|
cls = NonBlockHandler
|
||||||
|
cls.stoppers = []
|
||||||
|
super(NonBlockHandler, self).__init__(application, request, **kwargs)
|
||||||
|
|
||||||
@asynchronous
|
@asynchronous
|
||||||
def get(self, route):
|
def get(self, route):
|
||||||
|
|||||||
@@ -23,20 +23,22 @@ config = [{
|
|||||||
'default': '',
|
'default': '',
|
||||||
'type': 'password',
|
'type': 'password',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
'name': 'host',
|
|
||||||
'advanced': True,
|
|
||||||
'default': '0.0.0.0',
|
|
||||||
'hidden': True,
|
|
||||||
'label': 'IP',
|
|
||||||
'description': 'Host that I should listen to. "0.0.0.0" listens to all ips.',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
'name': 'port',
|
'name': 'port',
|
||||||
'default': 5050,
|
'default': 5050,
|
||||||
'type': 'int',
|
'type': 'int',
|
||||||
'description': 'The port I should listen to.',
|
'description': 'The port I should listen to.',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'name': 'ssl_cert',
|
||||||
|
'description': 'Path to SSL server.crt',
|
||||||
|
'advanced': True,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'ssl_key',
|
||||||
|
'description': 'Path to SSL server.key',
|
||||||
|
'advanced': True,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'name': 'launch_browser',
|
'name': 'launch_browser',
|
||||||
'default': True,
|
'default': True,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from uuid import uuid4
|
|||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import signal
|
import signal
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
import webbrowser
|
import webbrowser
|
||||||
@@ -178,6 +179,7 @@ class Core(Plugin):
|
|||||||
def signalHandler(self):
|
def signalHandler(self):
|
||||||
|
|
||||||
def signal_handler(signal, frame):
|
def signal_handler(signal, frame):
|
||||||
fireEvent('app.do_shutdown')
|
fireEvent('app.shutdown')
|
||||||
|
|
||||||
signal.signal(signal.SIGINT, signal_handler)
|
signal.signal(signal.SIGINT, signal_handler)
|
||||||
|
signal.signal(signal.SIGTERM, signal_handler)
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ from apscheduler.scheduler import Scheduler as Sched
|
|||||||
from couchpotato.core.event import addEvent
|
from couchpotato.core.event import addEvent
|
||||||
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
|
||||||
import logging
|
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
config = {
|
||||||
|
'name': 'download_providers',
|
||||||
|
'groups': [
|
||||||
|
{
|
||||||
|
'label': 'Downloaders',
|
||||||
|
'description': 'You can select different downloaders for each type (usenet / torrent)',
|
||||||
|
'type': 'list',
|
||||||
|
'name': 'download_providers',
|
||||||
|
'tab': 'downloaders',
|
||||||
|
'options': [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
from base64 import b32decode, b16encode
|
from base64 import b32decode, b16encode
|
||||||
from couchpotato.core.event import addEvent
|
from couchpotato.core.event import addEvent
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.plugins.base import Plugin
|
from couchpotato.core.providers.base import Provider
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Downloader(Plugin):
|
class Downloader(Provider):
|
||||||
|
|
||||||
type = []
|
type = []
|
||||||
|
http_time_between_calls = 0
|
||||||
|
|
||||||
torrent_sources = [
|
torrent_sources = [
|
||||||
'http://torrage.com/torrent/%s.torrent',
|
'http://torrage.com/torrent/%s.torrent',
|
||||||
@@ -32,18 +33,41 @@ class Downloader(Plugin):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
addEvent('download', self.download)
|
addEvent('download', self._download)
|
||||||
addEvent('download.status', self.getAllDownloadStatus)
|
addEvent('download.enabled', self._isEnabled)
|
||||||
addEvent('download.remove_failed', self.removeFailed)
|
addEvent('download.enabled_types', self.getEnabledDownloadType)
|
||||||
|
addEvent('download.status', self._getAllDownloadStatus)
|
||||||
|
addEvent('download.remove_failed', self._removeFailed)
|
||||||
|
|
||||||
def download(self, data = {}, movie = {}, manual = False, filedata = None):
|
def getEnabledDownloadType(self):
|
||||||
pass
|
for download_type in self.type:
|
||||||
|
if self.isEnabled(manual = True, data = {'type': download_type}):
|
||||||
|
return self.type
|
||||||
|
|
||||||
|
return []
|
||||||
|
|
||||||
|
def _download(self, data = {}, movie = {}, manual = False, filedata = None):
|
||||||
|
if self.isDisabled(manual, data):
|
||||||
|
return
|
||||||
|
return self.download(data = data, movie = movie, filedata = filedata)
|
||||||
|
|
||||||
|
def _getAllDownloadStatus(self):
|
||||||
|
if self.isDisabled(manual = True, data = {}):
|
||||||
|
return
|
||||||
|
|
||||||
|
return self.getAllDownloadStatus()
|
||||||
|
|
||||||
|
def _removeFailed(self, item):
|
||||||
|
if self.isDisabled(manual = True, data = {}):
|
||||||
|
return
|
||||||
|
|
||||||
|
if self.conf('delete_failed', default = True):
|
||||||
|
return self.removeFailed(item)
|
||||||
|
|
||||||
def getAllDownloadStatus(self):
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def removeFailed(self, name = {}, nzo_id = {}):
|
def removeFailed(self, item):
|
||||||
return False
|
return
|
||||||
|
|
||||||
def isCorrectType(self, item_type):
|
def isCorrectType(self, item_type):
|
||||||
is_correct = item_type in self.type
|
is_correct = item_type in self.type
|
||||||
@@ -76,9 +100,16 @@ class Downloader(Plugin):
|
|||||||
log.error('Failed converting magnet url to torrent: %s', (torrent_hash))
|
log.error('Failed converting magnet url to torrent: %s', (torrent_hash))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def isDisabled(self, manual):
|
def isDisabled(self, manual, data):
|
||||||
return not self.isEnabled(manual)
|
return not self.isEnabled(manual, data)
|
||||||
|
|
||||||
def isEnabled(self, manual):
|
def _isEnabled(self, manual, data = {}):
|
||||||
|
if not self.isEnabled(manual, data):
|
||||||
|
return
|
||||||
|
return True
|
||||||
|
|
||||||
|
def isEnabled(self, manual, data = {}):
|
||||||
d_manual = self.conf('manual', default = False)
|
d_manual = self.conf('manual', default = False)
|
||||||
return super(Downloader, self).isEnabled() and ((d_manual and manual) or (d_manual is False))
|
return super(Downloader, self).isEnabled() and \
|
||||||
|
((d_manual and manual) or (d_manual is False)) and \
|
||||||
|
(not data or self.isCorrectType(data.get('type')))
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'downloaders',
|
'tab': 'downloaders',
|
||||||
|
'list': 'download_providers',
|
||||||
'name': 'blackhole',
|
'name': 'blackhole',
|
||||||
'label': 'Black hole',
|
'label': 'Black hole',
|
||||||
'description': 'Download the NZB/Torrent to a specific folder.',
|
'description': 'Download the NZB/Torrent to a specific folder.',
|
||||||
|
|||||||
@@ -10,11 +10,7 @@ class Blackhole(Downloader):
|
|||||||
|
|
||||||
type = ['nzb', 'torrent', 'torrent_magnet']
|
type = ['nzb', 'torrent', 'torrent_magnet']
|
||||||
|
|
||||||
def download(self, data = {}, movie = {}, manual = False, filedata = None):
|
def download(self, data = {}, movie = {}, filedata = None):
|
||||||
if self.isDisabled(manual) or \
|
|
||||||
(not self.isCorrectType(data.get('type')) or \
|
|
||||||
(not self.conf('use_for') in ['both', 'torrent' if 'torrent' in data.get('type') else data.get('type')])):
|
|
||||||
return
|
|
||||||
|
|
||||||
directory = self.conf('directory')
|
directory = self.conf('directory')
|
||||||
if not directory or not os.path.isdir(directory):
|
if not directory or not os.path.isdir(directory):
|
||||||
@@ -52,4 +48,17 @@ class Blackhole(Downloader):
|
|||||||
except:
|
except:
|
||||||
log.info('Failed to download file %s: %s', (data.get('name'), traceback.format_exc()))
|
log.info('Failed to download file %s: %s', (data.get('name'), traceback.format_exc()))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def getEnabledDownloadType(self):
|
||||||
|
if self.conf('use_for') == 'both':
|
||||||
|
return super(Blackhole, self).getEnabledDownloadType()
|
||||||
|
elif self.conf('use_for') == 'torrent':
|
||||||
|
return ['torrent', 'torrent_magnet']
|
||||||
|
else:
|
||||||
|
return ['nzb']
|
||||||
|
|
||||||
|
def isEnabled(self, manual, data = {}):
|
||||||
|
return super(Blackhole, self).isEnabled(manual, data) and \
|
||||||
|
((self.conf('use_for') in ['both', 'torrent' if 'torrent' in data.get('type') else data.get('type')]))
|
||||||
|
|||||||
@@ -8,9 +8,10 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'downloaders',
|
'tab': 'downloaders',
|
||||||
|
'list': 'download_providers',
|
||||||
'name': 'nzbget',
|
'name': 'nzbget',
|
||||||
'label': 'NZBGet',
|
'label': 'NZBGet',
|
||||||
'description': 'Send NZBs to your NZBGet installation.',
|
'description': 'Use <a href="http://nzbget.sourceforge.net/Main_Page" target="_blank">NZBGet</a> to download NZBs.',
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
'name': 'enabled',
|
'name': 'enabled',
|
||||||
@@ -25,6 +26,7 @@ config = [{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'password',
|
'name': 'password',
|
||||||
|
'type': 'password',
|
||||||
'description': 'Default NZBGet password is <i>tegbzn6789</i>',
|
'description': 'Default NZBGet password is <i>tegbzn6789</i>',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -32,6 +34,13 @@ config = [{
|
|||||||
'default': 'Movies',
|
'default': 'Movies',
|
||||||
'description': 'The category CP places the nzb in. Like <strong>movies</strong> or <strong>couchpotato</strong>',
|
'description': 'The category CP places the nzb in. Like <strong>movies</strong> or <strong>couchpotato</strong>',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'name': 'priority',
|
||||||
|
'default': '0',
|
||||||
|
'type': 'dropdown',
|
||||||
|
'values': [('Very Low', -100), ('Low', -50), ('Normal', 0), ('High', 50), ('Very High', 100)],
|
||||||
|
'description': 'Only change this if you are using NZBget 9.0 or higher',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'name': 'manual',
|
'name': 'manual',
|
||||||
'default': 0,
|
'default': 0,
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
from base64 import standard_b64encode
|
from base64 import standard_b64encode
|
||||||
from couchpotato.core.downloaders.base import Downloader
|
from couchpotato.core.downloaders.base import Downloader
|
||||||
|
from couchpotato.core.helpers.variable import tryInt
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from inspect import isfunction
|
import re
|
||||||
import socket
|
import socket
|
||||||
import traceback
|
import traceback
|
||||||
import xmlrpclib
|
import xmlrpclib
|
||||||
@@ -14,10 +15,7 @@ class NZBGet(Downloader):
|
|||||||
|
|
||||||
url = 'http://nzbget:%(password)s@%(host)s/xmlrpc'
|
url = 'http://nzbget:%(password)s@%(host)s/xmlrpc'
|
||||||
|
|
||||||
def download(self, data = {}, movie = {}, manual = False, filedata = None):
|
def download(self, data = {}, movie = {}, filedata = None):
|
||||||
|
|
||||||
if self.isDisabled(manual) or not self.isCorrectType(data.get('type')):
|
|
||||||
return
|
|
||||||
|
|
||||||
if not filedata:
|
if not filedata:
|
||||||
log.error('Unable to get NZB file: %s', traceback.format_exc())
|
log.error('Unable to get NZB file: %s', traceback.format_exc())
|
||||||
@@ -44,7 +42,12 @@ class NZBGet(Downloader):
|
|||||||
log.error('Protocol Error: %s', e)
|
log.error('Protocol Error: %s', e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if rpc.append(nzb_name, self.conf('category'), False, standard_b64encode(filedata.strip())):
|
if re.search(r"^0", rpc.version()):
|
||||||
|
xml_response = rpc.append(nzb_name, self.conf('category'), False, standard_b64encode(filedata.strip()))
|
||||||
|
else:
|
||||||
|
xml_response = rpc.append(nzb_name, self.conf('category'), tryInt(self.conf('priority')), False, standard_b64encode(filedata.strip()))
|
||||||
|
|
||||||
|
if xml_response:
|
||||||
log.info('NZB sent successfully to NZBGet')
|
log.info('NZB sent successfully to NZBGet')
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
from .main import NZBVortex
|
||||||
|
|
||||||
|
def start():
|
||||||
|
return NZBVortex()
|
||||||
|
|
||||||
|
config = [{
|
||||||
|
'name': 'nzbvortex',
|
||||||
|
'groups': [
|
||||||
|
{
|
||||||
|
'tab': 'downloaders',
|
||||||
|
'list': 'download_providers',
|
||||||
|
'name': 'nzbvortex',
|
||||||
|
'label': 'NZBVortex',
|
||||||
|
'description': 'Use <a href="http://www.nzbvortex.com/landing/" target="_blank">NZBVortex</a> to download NZBs.',
|
||||||
|
'wizard': True,
|
||||||
|
'options': [
|
||||||
|
{
|
||||||
|
'name': 'enabled',
|
||||||
|
'default': 0,
|
||||||
|
'type': 'enabler',
|
||||||
|
'radio_group': 'nzb',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'host',
|
||||||
|
'default': 'https://localhost:4321',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'api_key',
|
||||||
|
'label': 'Api Key',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'manual',
|
||||||
|
'default': False,
|
||||||
|
'type': 'bool',
|
||||||
|
'advanced': True,
|
||||||
|
'description': 'Disable this downloader for automated searches, but use it when I manually send a release.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'delete_failed',
|
||||||
|
'default': True,
|
||||||
|
'type': 'bool',
|
||||||
|
'description': 'Delete a release after the download has failed.',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}]
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
from base64 import b64encode
|
||||||
|
from couchpotato.core.downloaders.base import Downloader
|
||||||
|
from couchpotato.core.helpers.encoding import tryUrlencode, ss
|
||||||
|
from couchpotato.core.helpers.variable import cleanHost
|
||||||
|
from couchpotato.core.logger import CPLog
|
||||||
|
from urllib2 import URLError
|
||||||
|
from uuid import uuid4
|
||||||
|
import hashlib
|
||||||
|
import httplib
|
||||||
|
import json
|
||||||
|
import socket
|
||||||
|
import ssl
|
||||||
|
import sys
|
||||||
|
import traceback
|
||||||
|
import urllib2
|
||||||
|
|
||||||
|
log = CPLog(__name__)
|
||||||
|
|
||||||
|
class NZBVortex(Downloader):
|
||||||
|
|
||||||
|
type = ['nzb']
|
||||||
|
api_level = None
|
||||||
|
session_id = None
|
||||||
|
|
||||||
|
def download(self, data = {}, movie = {}, filedata = None):
|
||||||
|
|
||||||
|
# Send the nzb
|
||||||
|
try:
|
||||||
|
nzb_filename = self.createFileName(data, filedata, movie)
|
||||||
|
self.call('nzb/add', params = {'file': (ss(nzb_filename), filedata)}, multipart = True)
|
||||||
|
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
log.error('Something went wrong sending the NZB file: %s', traceback.format_exc())
|
||||||
|
return False
|
||||||
|
|
||||||
|
def getAllDownloadStatus(self):
|
||||||
|
|
||||||
|
raw_statuses = self.call('nzb')
|
||||||
|
|
||||||
|
statuses = []
|
||||||
|
for item in raw_statuses.get('nzbs', []):
|
||||||
|
|
||||||
|
# Check status
|
||||||
|
status = 'busy'
|
||||||
|
if item['state'] == 20:
|
||||||
|
status = 'completed'
|
||||||
|
elif item['state'] in [21, 22, 24]:
|
||||||
|
status = 'failed'
|
||||||
|
|
||||||
|
statuses.append({
|
||||||
|
'id': item['id'],
|
||||||
|
'name': item['uiTitle'],
|
||||||
|
'status': status,
|
||||||
|
'original_status': item['state'],
|
||||||
|
'timeleft':-1,
|
||||||
|
})
|
||||||
|
|
||||||
|
return statuses
|
||||||
|
|
||||||
|
def removeFailed(self, item):
|
||||||
|
|
||||||
|
log.info('%s failed downloading, deleting...', item['name'])
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.call('nzb/%s/cancel' % item['id'])
|
||||||
|
except:
|
||||||
|
log.error('Failed deleting: %s', traceback.format_exc(0))
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def login(self):
|
||||||
|
|
||||||
|
nonce = self.call('auth/nonce', auth = False).get('authNonce')
|
||||||
|
cnonce = uuid4().hex
|
||||||
|
hashed = b64encode(hashlib.sha256('%s:%s:%s' % (nonce, cnonce, self.conf('api_key'))).digest())
|
||||||
|
|
||||||
|
params = {
|
||||||
|
'nonce': nonce,
|
||||||
|
'cnonce': cnonce,
|
||||||
|
'hash': hashed
|
||||||
|
}
|
||||||
|
|
||||||
|
login_data = self.call('auth/login', parameters = params, auth = False)
|
||||||
|
|
||||||
|
# Save for later
|
||||||
|
if login_data.get('loginResult') == 'successful':
|
||||||
|
self.session_id = login_data.get('sessionID')
|
||||||
|
return True
|
||||||
|
|
||||||
|
log.error('Login failed, please check you api-key')
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def call(self, call, parameters = {}, repeat = False, auth = True, *args, **kwargs):
|
||||||
|
|
||||||
|
# Login first
|
||||||
|
if not self.session_id and auth:
|
||||||
|
self.login()
|
||||||
|
|
||||||
|
# Always add session id to request
|
||||||
|
if self.session_id:
|
||||||
|
parameters['sessionid'] = self.session_id
|
||||||
|
|
||||||
|
params = tryUrlencode(parameters)
|
||||||
|
|
||||||
|
url = cleanHost(self.conf('host')) + 'api/' + call
|
||||||
|
url_opener = urllib2.build_opener(HTTPSHandler())
|
||||||
|
|
||||||
|
try:
|
||||||
|
data = self.urlopen('%s?%s' % (url, params), opener = url_opener, *args, **kwargs)
|
||||||
|
|
||||||
|
if data:
|
||||||
|
return json.loads(data)
|
||||||
|
except URLError, e:
|
||||||
|
if hasattr(e, 'code') and e.code == 403:
|
||||||
|
# Try login and do again
|
||||||
|
if not repeat:
|
||||||
|
self.login()
|
||||||
|
return self.call(call, parameters = parameters, repeat = True, *args, **kwargs)
|
||||||
|
|
||||||
|
log.error('Failed to parsing %s: %s', (self.getName(), traceback.format_exc()))
|
||||||
|
except:
|
||||||
|
log.error('Failed to parsing %s: %s', (self.getName(), traceback.format_exc()))
|
||||||
|
|
||||||
|
return {}
|
||||||
|
|
||||||
|
def getApiLevel(self):
|
||||||
|
|
||||||
|
if not self.api_level:
|
||||||
|
|
||||||
|
url = cleanHost(self.conf('host')) + 'api/app/apilevel'
|
||||||
|
url_opener = urllib2.build_opener(HTTPSHandler())
|
||||||
|
|
||||||
|
try:
|
||||||
|
data = self.urlopen(url, opener = url_opener, show_error = False)
|
||||||
|
self.api_level = float(json.loads(data).get('apilevel'))
|
||||||
|
except URLError, e:
|
||||||
|
if hasattr(e, 'code') and e.code == 403:
|
||||||
|
log.error('This version of NZBVortex isn\'t supported. Please update to 2.8.6 or higher')
|
||||||
|
else:
|
||||||
|
log.error('NZBVortex doesn\'t seem to be running or maybe the remote option isn\'t enabled yet: %s', traceback.format_exc(1))
|
||||||
|
|
||||||
|
return self.api_level
|
||||||
|
|
||||||
|
def isEnabled(self, manual, data):
|
||||||
|
return super(NZBVortex, self).isEnabled(manual, data) and self.getApiLevel()
|
||||||
|
|
||||||
|
|
||||||
|
class HTTPSConnection(httplib.HTTPSConnection):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
httplib.HTTPSConnection.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
|
def connect(self):
|
||||||
|
sock = socket.create_connection((self.host, self.port), self.timeout)
|
||||||
|
if sys.version_info < (2, 6, 7):
|
||||||
|
if hasattr(self, '_tunnel_host'):
|
||||||
|
self.sock = sock
|
||||||
|
self._tunnel()
|
||||||
|
else:
|
||||||
|
if self._tunnel_host:
|
||||||
|
self.sock = sock
|
||||||
|
self._tunnel()
|
||||||
|
|
||||||
|
self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file, ssl_version = ssl.PROTOCOL_TLSv1)
|
||||||
|
|
||||||
|
class HTTPSHandler(urllib2.HTTPSHandler):
|
||||||
|
def https_open(self, req):
|
||||||
|
return self.do_open(HTTPSConnection, req)
|
||||||
@@ -9,9 +9,10 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'downloaders',
|
'tab': 'downloaders',
|
||||||
|
'list': 'download_providers',
|
||||||
'name': 'pneumatic',
|
'name': 'pneumatic',
|
||||||
'label': 'Pneumatic',
|
'label': 'Pneumatic',
|
||||||
'description': 'Download the .strm file to a specific folder.',
|
'description': 'Use <a href="http://forum.xbmc.org/showthread.php?tid=97657" target="_blank">Pneumatic</a> to download .strm files.',
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
'name': 'enabled',
|
'name': 'enabled',
|
||||||
|
|||||||
@@ -11,9 +11,7 @@ class Pneumatic(Downloader):
|
|||||||
type = ['nzb']
|
type = ['nzb']
|
||||||
strm_syntax = 'plugin://plugin.program.pneumatic/?mode=strm&type=add_file&nzb=%s&nzbname=%s'
|
strm_syntax = 'plugin://plugin.program.pneumatic/?mode=strm&type=add_file&nzb=%s&nzbname=%s'
|
||||||
|
|
||||||
def download(self, data = {}, movie = {}, manual = False, filedata = None):
|
def download(self, data = {}, movie = {}, filedata = None):
|
||||||
if self.isDisabled(manual) or (not self.isCorrectType(data.get('type'))):
|
|
||||||
return
|
|
||||||
|
|
||||||
directory = self.conf('directory')
|
directory = self.conf('directory')
|
||||||
if not directory or not os.path.isdir(directory):
|
if not directory or not os.path.isdir(directory):
|
||||||
|
|||||||
@@ -8,9 +8,10 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'downloaders',
|
'tab': 'downloaders',
|
||||||
|
'list': 'download_providers',
|
||||||
'name': 'sabnzbd',
|
'name': 'sabnzbd',
|
||||||
'label': 'Sabnzbd',
|
'label': 'Sabnzbd',
|
||||||
'description': 'Send NZBs to your Sabnzbd installation.',
|
'description': 'Use <a href="http://sabnzbd.org/" target="_blank">SABnzbd</a> to download NZBs.',
|
||||||
'wizard': True,
|
'wizard': True,
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from couchpotato.core.downloaders.base import Downloader
|
from couchpotato.core.downloaders.base import Downloader
|
||||||
from couchpotato.core.helpers.encoding import tryUrlencode
|
from couchpotato.core.helpers.encoding import tryUrlencode, ss
|
||||||
from couchpotato.core.helpers.variable import cleanHost, mergeDicts
|
from couchpotato.core.helpers.variable import cleanHost, mergeDicts
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from urllib2 import URLError
|
from urllib2 import URLError
|
||||||
@@ -12,10 +12,7 @@ class Sabnzbd(Downloader):
|
|||||||
|
|
||||||
type = ['nzb']
|
type = ['nzb']
|
||||||
|
|
||||||
def download(self, data = {}, movie = {}, manual = False, filedata = None):
|
def download(self, data = {}, movie = {}, filedata = None):
|
||||||
|
|
||||||
if self.isDisabled(manual) or not self.isCorrectType(data.get('type')):
|
|
||||||
return
|
|
||||||
|
|
||||||
log.info('Sending "%s" to SABnzbd.', data.get('name'))
|
log.info('Sending "%s" to SABnzbd.', data.get('name'))
|
||||||
|
|
||||||
@@ -41,7 +38,7 @@ class Sabnzbd(Downloader):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if params.get('mode') is 'addfile':
|
if params.get('mode') is 'addfile':
|
||||||
sab = self.urlopen(url, timeout = 60, params = {'nzbfile': (nzb_filename, filedata)}, multipart = True, show_error = False)
|
sab = self.urlopen(url, timeout = 60, params = {'nzbfile': (ss(nzb_filename), filedata)}, multipart = True, show_error = False)
|
||||||
else:
|
else:
|
||||||
sab = self.urlopen(url, timeout = 60, show_error = False)
|
sab = self.urlopen(url, timeout = 60, show_error = False)
|
||||||
except URLError:
|
except URLError:
|
||||||
@@ -65,8 +62,6 @@ class Sabnzbd(Downloader):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def getAllDownloadStatus(self):
|
def getAllDownloadStatus(self):
|
||||||
if self.isDisabled(manual = False):
|
|
||||||
return False
|
|
||||||
|
|
||||||
log.debug('Checking SABnzbd download status.')
|
log.debug('Checking SABnzbd download status.')
|
||||||
|
|
||||||
@@ -122,9 +117,6 @@ class Sabnzbd(Downloader):
|
|||||||
|
|
||||||
def removeFailed(self, item):
|
def removeFailed(self, item):
|
||||||
|
|
||||||
if not self.conf('delete_failed', default = True):
|
|
||||||
return False
|
|
||||||
|
|
||||||
log.info('%s failed downloading, deleting...', item['name'])
|
log.info('%s failed downloading, deleting...', item['name'])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -8,9 +8,10 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'downloaders',
|
'tab': 'downloaders',
|
||||||
|
'list': 'download_providers',
|
||||||
'name': 'synology',
|
'name': 'synology',
|
||||||
'label': 'Synology',
|
'label': 'Synology',
|
||||||
'description': 'Send torrents to Synology\'s Download Station.',
|
'description': 'Use <a href="http://www.synology.com/dsm/home_home_applications_download_station.php" target="_blank">Synology Download Station</a> to download.',
|
||||||
'wizard': True,
|
'wizard': True,
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,10 +14,7 @@ class Synology(Downloader):
|
|||||||
type = ['torrent_magnet']
|
type = ['torrent_magnet']
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
def download(self, data, movie, manual = False, filedata = None):
|
def download(self, data, movie, filedata = None):
|
||||||
|
|
||||||
if self.isDisabled(manual) or not self.isCorrectType(data.get('type')):
|
|
||||||
return
|
|
||||||
|
|
||||||
log.error('Sending "%s" (%s) to Synology.', (data.get('name'), data.get('type')))
|
log.error('Sending "%s" (%s) to Synology.', (data.get('name'), data.get('type')))
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,10 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'downloaders',
|
'tab': 'downloaders',
|
||||||
|
'list': 'download_providers',
|
||||||
'name': 'transmission',
|
'name': 'transmission',
|
||||||
'label': 'Transmission',
|
'label': 'Transmission',
|
||||||
'description': 'Send torrents to Transmission.',
|
'description': 'Use <a href="http://www.transmissionbt.com/" target="_blank">Transmission</a> to download torrents.',
|
||||||
'wizard': True,
|
'wizard': True,
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,10 +16,7 @@ class Transmission(Downloader):
|
|||||||
type = ['torrent', 'torrent_magnet']
|
type = ['torrent', 'torrent_magnet']
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
def download(self, data, movie, manual = False, filedata = None):
|
def download(self, data, movie, filedata = None):
|
||||||
|
|
||||||
if self.isDisabled(manual) or not self.isCorrectType(data.get('type')):
|
|
||||||
return
|
|
||||||
|
|
||||||
log.debug('Sending "%s" (%s) to Transmission.', (data.get('name'), data.get('type')))
|
log.debug('Sending "%s" (%s) to Transmission.', (data.get('name'), data.get('type')))
|
||||||
|
|
||||||
@@ -41,10 +38,11 @@ class Transmission(Downloader):
|
|||||||
'download-dir': folder_path
|
'download-dir': folder_path
|
||||||
}
|
}
|
||||||
|
|
||||||
torrent_params = {
|
if self.conf('ratio'):
|
||||||
'seedRatioLimit': self.conf('ratio'),
|
torrent_params = {
|
||||||
'seedRatioMode': (0 if self.conf('ratio') else 1)
|
'seedRatioLimit': self.conf('ratio'),
|
||||||
}
|
'seedRatioMode': self.conf('ratio')
|
||||||
|
}
|
||||||
|
|
||||||
if not filedata and data.get('type') == 'torrent':
|
if not filedata and data.get('type') == 'torrent':
|
||||||
log.error('Failed sending torrent, no data')
|
log.error('Failed sending torrent, no data')
|
||||||
|
|||||||
@@ -8,9 +8,10 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'downloaders',
|
'tab': 'downloaders',
|
||||||
|
'list': 'download_providers',
|
||||||
'name': 'utorrent',
|
'name': 'utorrent',
|
||||||
'label': 'uTorrent',
|
'label': 'uTorrent',
|
||||||
'description': 'Send torrents to uTorrent.',
|
'description': 'Use <a href="http://www.utorrent.com/" target="_blank">uTorrent</a> to download torrents.',
|
||||||
'wizard': True,
|
'wizard': True,
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from bencode import bencode, bdecode
|
from bencode import bencode, bdecode
|
||||||
from couchpotato.core.downloaders.base import Downloader
|
from couchpotato.core.downloaders.base import Downloader
|
||||||
from couchpotato.core.helpers.encoding import isInt
|
from couchpotato.core.helpers.encoding import isInt, ss
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
from multipartpost import MultipartPostHandler
|
from multipartpost import MultipartPostHandler
|
||||||
@@ -20,10 +20,7 @@ class uTorrent(Downloader):
|
|||||||
type = ['torrent', 'torrent_magnet']
|
type = ['torrent', 'torrent_magnet']
|
||||||
utorrent_api = None
|
utorrent_api = None
|
||||||
|
|
||||||
def download(self, data, movie, manual = False, filedata = None):
|
def download(self, data, movie, filedata = None):
|
||||||
|
|
||||||
if self.isDisabled(manual) or not self.isCorrectType(data.get('type')):
|
|
||||||
return
|
|
||||||
|
|
||||||
log.debug('Sending "%s" (%s) to uTorrent.', (data.get('name'), data.get('type')))
|
log.debug('Sending "%s" (%s) to uTorrent.', (data.get('name'), data.get('type')))
|
||||||
|
|
||||||
@@ -125,7 +122,7 @@ class uTorrentAPI(object):
|
|||||||
|
|
||||||
def add_torrent_file(self, filename, filedata):
|
def add_torrent_file(self, filename, filedata):
|
||||||
action = "action=add-file"
|
action = "action=add-file"
|
||||||
return self._request(action, {"torrent_file": (filename, filedata)})
|
return self._request(action, {"torrent_file": (ss(filename), filedata)})
|
||||||
|
|
||||||
def set_torrent(self, hash, params):
|
def set_torrent(self, hash, params):
|
||||||
action = "action=setprops&hash=%s" % hash
|
action = "action=setprops&hash=%s" % hash
|
||||||
|
|||||||
@@ -115,7 +115,8 @@ def fireEvent(name, *args, **kwargs):
|
|||||||
elif isinstance(results[0], list):
|
elif isinstance(results[0], list):
|
||||||
merged = []
|
merged = []
|
||||||
for result in results:
|
for result in results:
|
||||||
merged += result
|
if result not in merged:
|
||||||
|
merged += result
|
||||||
|
|
||||||
results = merged
|
results = merged
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,18 @@ class Loader(object):
|
|||||||
|
|
||||||
def addFromDir(self, plugin_type, priority, module, dir_name):
|
def addFromDir(self, plugin_type, priority, module, dir_name):
|
||||||
|
|
||||||
|
# Load dir module
|
||||||
|
try:
|
||||||
|
m = __import__(module)
|
||||||
|
splitted = module.split('.')
|
||||||
|
for sub in splitted[1:]:
|
||||||
|
m = getattr(m, sub)
|
||||||
|
|
||||||
|
if hasattr(m, 'config'):
|
||||||
|
fireEvent('settings.options', splitted[-1] + '_config', getattr(m, 'config'))
|
||||||
|
except:
|
||||||
|
raise
|
||||||
|
|
||||||
for cur_file in glob.glob(os.path.join(dir_name, '*')):
|
for cur_file in glob.glob(os.path.join(dir_name, '*')):
|
||||||
name = os.path.basename(cur_file)
|
name = os.path.basename(cur_file)
|
||||||
if os.path.isdir(os.path.join(dir_name, name)):
|
if os.path.isdir(os.path.join(dir_name, name)):
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
config = {
|
||||||
|
'name': 'notification_providers',
|
||||||
|
'groups': [
|
||||||
|
{
|
||||||
|
'label': 'Notifications',
|
||||||
|
'description': 'Notify when movies are done or snatched',
|
||||||
|
'type': 'list',
|
||||||
|
'name': 'notification_providers',
|
||||||
|
'tab': 'notifications',
|
||||||
|
'options': [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'notifications',
|
'tab': 'notifications',
|
||||||
|
'list': 'notification_providers',
|
||||||
'name': 'boxcar',
|
'name': 'boxcar',
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
from .main import Email
|
||||||
|
|
||||||
|
def start():
|
||||||
|
return Email()
|
||||||
|
|
||||||
|
config = [{
|
||||||
|
'name': 'email',
|
||||||
|
'groups': [
|
||||||
|
{
|
||||||
|
'tab': 'notifications',
|
||||||
|
'list': 'notification_providers',
|
||||||
|
'name': 'email',
|
||||||
|
'options': [
|
||||||
|
{
|
||||||
|
'name': 'enabled',
|
||||||
|
'default': 0,
|
||||||
|
'type': 'enabler',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'from',
|
||||||
|
'label': 'Send e-mail from',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'to',
|
||||||
|
'label': 'Send e-mail to',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'smtp_server',
|
||||||
|
'label': 'SMTP server',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'ssl',
|
||||||
|
'label': 'Enable SSL',
|
||||||
|
'default': 0,
|
||||||
|
'type': 'bool',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'smtp_user',
|
||||||
|
'label': 'SMTP user',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'smtp_pass',
|
||||||
|
'label': 'SMTP password',
|
||||||
|
'type': 'password',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'on_snatch',
|
||||||
|
'default': 0,
|
||||||
|
'type': 'bool',
|
||||||
|
'advanced': True,
|
||||||
|
'description': 'Also send message when movie is snatched.',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}]
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
from couchpotato.core.helpers.encoding import toUnicode
|
||||||
|
from couchpotato.core.logger import CPLog
|
||||||
|
from couchpotato.core.notifications.base import Notification
|
||||||
|
from email.mime.text import MIMEText
|
||||||
|
import smtplib
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
log = CPLog(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class Email(Notification):
|
||||||
|
|
||||||
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
|
if self.isDisabled(): return
|
||||||
|
|
||||||
|
# Extract all the settings from settings
|
||||||
|
from_address = self.conf('from')
|
||||||
|
to_address = self.conf('to')
|
||||||
|
ssl = self.conf('ssl')
|
||||||
|
smtp_server = self.conf('smtp_server')
|
||||||
|
smtp_user = self.conf('smtp_user')
|
||||||
|
smtp_pass = self.conf('smtp_pass')
|
||||||
|
|
||||||
|
# Make the basic message
|
||||||
|
message = MIMEText(toUnicode(message))
|
||||||
|
message['Subject'] = self.default_title
|
||||||
|
message['From'] = from_address
|
||||||
|
message['To'] = to_address
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Open the SMTP connection, via SSL if requested
|
||||||
|
log.debug("SMTP over SSL %s", ("enabled" if ssl == 1 else "disabled"))
|
||||||
|
mailserver = smtplib.SMTP_SSL(smtp_server) if ssl == 1 else smtplib.SMTP(smtp_server)
|
||||||
|
|
||||||
|
# Check too see if an login attempt should be attempted
|
||||||
|
if len(smtp_user) > 0:
|
||||||
|
log.debug("Logging on to SMTP server using username \'%s\'%s", (smtp_user, " and a password" if len(smtp_pass) > 0 else ""))
|
||||||
|
mailserver.login(smtp_user, smtp_pass)
|
||||||
|
|
||||||
|
# Send the e-mail
|
||||||
|
log.debug("Sending the email")
|
||||||
|
mailserver.sendmail(from_address, to_address, message.as_string())
|
||||||
|
|
||||||
|
# Close the SMTP connection
|
||||||
|
mailserver.quit()
|
||||||
|
|
||||||
|
log.info('Email notification sent')
|
||||||
|
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
log.error('E-mail failed: %s', traceback.format_exc())
|
||||||
|
return False
|
||||||
|
|
||||||
|
return False
|
||||||
@@ -8,6 +8,7 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'notifications',
|
'tab': 'notifications',
|
||||||
|
'list': 'notification_providers',
|
||||||
'name': 'growl',
|
'name': 'growl',
|
||||||
'description': 'Version 1.4+',
|
'description': 'Version 1.4+',
|
||||||
'options': [
|
'options': [
|
||||||
|
|||||||
@@ -37,8 +37,11 @@ class Growl(Notification):
|
|||||||
)
|
)
|
||||||
self.growl.register()
|
self.growl.register()
|
||||||
self.registered = True
|
self.registered = True
|
||||||
except:
|
except Exception, e:
|
||||||
log.error('Failed register of growl: %s', traceback.format_exc())
|
if 'timed out' in str(e):
|
||||||
|
self.registered = True
|
||||||
|
else:
|
||||||
|
log.error('Failed register of growl: %s', traceback.format_exc())
|
||||||
|
|
||||||
def notify(self, message = '', data = {}, listener = None):
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
if self.isDisabled(): return
|
if self.isDisabled(): return
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'notifications',
|
'tab': 'notifications',
|
||||||
|
'list': 'notification_providers',
|
||||||
'name': 'nmj',
|
'name': 'nmj',
|
||||||
'label': 'NMJ',
|
'label': 'NMJ',
|
||||||
'options': [
|
'options': [
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'notifications',
|
'tab': 'notifications',
|
||||||
|
'list': 'notification_providers',
|
||||||
'name': 'notifo',
|
'name': 'notifo',
|
||||||
'description': 'Keep in mind that Notifo service will end soon.',
|
'description': 'Keep in mind that Notifo service will end soon.',
|
||||||
'options': [
|
'options': [
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'notifications',
|
'tab': 'notifications',
|
||||||
|
'list': 'notification_providers',
|
||||||
'name': 'notifymyandroid',
|
'name': 'notifymyandroid',
|
||||||
'label': 'Notify My Android',
|
'label': 'Notify My Android',
|
||||||
'options': [
|
'options': [
|
||||||
|
|||||||
@@ -8,8 +8,9 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'notifications',
|
'tab': 'notifications',
|
||||||
|
'list': 'notification_providers',
|
||||||
'name': 'notifymywp',
|
'name': 'notifymywp',
|
||||||
'label': 'Notify My Windows Phone',
|
'label': 'Windows Phone',
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
'name': 'enabled',
|
'name': 'enabled',
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'notifications',
|
'tab': 'notifications',
|
||||||
|
'list': 'notification_providers',
|
||||||
'name': 'plex',
|
'name': 'plex',
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'notifications',
|
'tab': 'notifications',
|
||||||
|
'list': 'notification_providers',
|
||||||
'name': 'prowl',
|
'name': 'prowl',
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'notifications',
|
'tab': 'notifications',
|
||||||
|
'list': 'notification_providers',
|
||||||
'name': 'pushover',
|
'name': 'pushover',
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'notifications',
|
'tab': 'notifications',
|
||||||
|
'list': 'notification_providers',
|
||||||
'name': 'synoindex',
|
'name': 'synoindex',
|
||||||
'description': 'Automaticly adds index to Synology Media Server.',
|
'description': 'Automaticly adds index to Synology Media Server.',
|
||||||
'options': [
|
'options': [
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
from .main import Toasty
|
||||||
|
|
||||||
|
def start():
|
||||||
|
return Toasty()
|
||||||
|
|
||||||
|
config = [{
|
||||||
|
'name': 'toasty',
|
||||||
|
'groups': [
|
||||||
|
{
|
||||||
|
'tab': 'notifications',
|
||||||
|
'list': 'notification_providers',
|
||||||
|
'name': 'toasty',
|
||||||
|
'options': [
|
||||||
|
{
|
||||||
|
'name': 'enabled',
|
||||||
|
'default': 0,
|
||||||
|
'type': 'enabler',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'api_key',
|
||||||
|
'label': 'Device ID',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'on_snatch',
|
||||||
|
'default': 0,
|
||||||
|
'type': 'bool',
|
||||||
|
'advanced': True,
|
||||||
|
'description': 'Also send message when movie is snatched.',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}]
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode
|
||||||
|
from couchpotato.core.logger import CPLog
|
||||||
|
from couchpotato.core.notifications.base import Notification
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
log = CPLog(__name__)
|
||||||
|
|
||||||
|
class Toasty(Notification):
|
||||||
|
|
||||||
|
urls = {
|
||||||
|
'api': 'http://api.supertoasty.com/notify/%s?%s'
|
||||||
|
}
|
||||||
|
|
||||||
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
|
if self.isDisabled(): return
|
||||||
|
|
||||||
|
data = {
|
||||||
|
'title': self.default_title,
|
||||||
|
'text': toUnicode(message),
|
||||||
|
'sender': toUnicode("CouchPotato"),
|
||||||
|
'image': 'https://raw.github.com/RuudBurger/CouchPotatoServer/master/couchpotato/static/images/homescreen.png',
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.urlopen(self.urls['api'] % (self.conf('api_key'), tryUrlencode(data)), show_error = False)
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
log.error('Toasty failed: %s', traceback.format_exc())
|
||||||
|
|
||||||
|
return False
|
||||||
@@ -8,6 +8,7 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'notifications',
|
'tab': 'notifications',
|
||||||
|
'list': 'notification_providers',
|
||||||
'name': 'twitter',
|
'name': 'twitter',
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,8 +8,10 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'notifications',
|
'tab': 'notifications',
|
||||||
|
'list': 'notification_providers',
|
||||||
'name': 'xbmc',
|
'name': 'xbmc',
|
||||||
'label': 'XBMC',
|
'label': 'XBMC',
|
||||||
|
'description': 'v11 (Eden) and v12 (Frodo)',
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
'name': 'enabled',
|
'name': 'enabled',
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from couchpotato.core.notifications.base import Notification
|
|||||||
from flask.helpers import json
|
from flask.helpers import json
|
||||||
import base64
|
import base64
|
||||||
import traceback
|
import traceback
|
||||||
|
import urllib
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
@@ -11,27 +12,148 @@ log = CPLog(__name__)
|
|||||||
class XBMC(Notification):
|
class XBMC(Notification):
|
||||||
|
|
||||||
listen_to = ['renamer.after']
|
listen_to = ['renamer.after']
|
||||||
|
use_json_notifications = {}
|
||||||
|
couch_logo_url = 'https://raw.github.com/RuudBurger/CouchPotatoServer/master/couchpotato/static/images/xbmc-notify.png'
|
||||||
|
|
||||||
def notify(self, message = '', data = {}, listener = None):
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
if self.isDisabled(): return
|
if self.isDisabled(): return
|
||||||
|
|
||||||
hosts = splitString(self.conf('host'))
|
hosts = splitString(self.conf('host'))
|
||||||
|
|
||||||
successful = 0
|
successful = 0
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
response = self.request(host, [
|
|
||||||
('GUI.ShowNotification', {"title":"CouchPotato", "message":message}),
|
if self.use_json_notifications.get(host) is None:
|
||||||
('VideoLibrary.Scan', {}),
|
self.getXBMCJSONversion(host, message = message)
|
||||||
])
|
|
||||||
|
if self.use_json_notifications.get(host):
|
||||||
|
response = self.request(host, [
|
||||||
|
('GUI.ShowNotification', {'title': self.default_title, 'message': message, 'image': self.couch_logo_url}),
|
||||||
|
('VideoLibrary.Scan', {}),
|
||||||
|
])
|
||||||
|
else:
|
||||||
|
response = self.notifyXBMCnoJSON(host, {'title':self.default_title, 'message':message})
|
||||||
|
response += self.request(host, [('VideoLibrary.Scan', {})])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for result in response:
|
for result in response:
|
||||||
if result['result'] == "OK":
|
if (result.get('result') and result['result'] == 'OK'):
|
||||||
successful += 1
|
successful += 1
|
||||||
|
elif (result.get('error')):
|
||||||
|
log.error('XBMC error; %s: %s (%s)', (result['id'], result['error']['message'], result['error']['code']))
|
||||||
|
|
||||||
except:
|
except:
|
||||||
log.error('Failed parsing results: %s', traceback.format_exc())
|
log.error('Failed parsing results: %s', traceback.format_exc())
|
||||||
|
|
||||||
return successful == len(hosts) * 2
|
return successful == len(hosts) * 2
|
||||||
|
|
||||||
|
def getXBMCJSONversion(self, host, message = ''):
|
||||||
|
|
||||||
|
success = False
|
||||||
|
|
||||||
|
# XBMC JSON-RPC version request
|
||||||
|
response = self.request(host, [
|
||||||
|
('JSONRPC.Version', {})
|
||||||
|
])
|
||||||
|
for result in response:
|
||||||
|
if (result.get('result') and type(result['result']['version']).__name__ == 'int'):
|
||||||
|
# only v2 and v4 return an int object
|
||||||
|
# v6 (as of XBMC v12(Frodo)) is required to send notifications
|
||||||
|
xbmc_rpc_version = str(result['result']['version'])
|
||||||
|
|
||||||
|
log.debug('XBMC JSON-RPC Version: %s ; Notifications by JSON-RPC only supported for v6 [as of XBMC v12(Frodo)]', xbmc_rpc_version)
|
||||||
|
|
||||||
|
# disable JSON use
|
||||||
|
self.use_json_notifications[host] = False
|
||||||
|
|
||||||
|
# send the text message
|
||||||
|
resp = self.notifyXBMCnoJSON(host, {'title':self.default_title, 'message':message})
|
||||||
|
for result in resp:
|
||||||
|
if (result.get('result') and result['result'] == 'OK'):
|
||||||
|
log.debug('Message delivered successfully!')
|
||||||
|
success = True
|
||||||
|
break
|
||||||
|
elif (result.get('error')):
|
||||||
|
log.error('XBMC error; %s: %s (%s)', (result['id'], result['error']['message'], result['error']['code']))
|
||||||
|
break
|
||||||
|
|
||||||
|
elif (result.get('result') and type(result['result']['version']).__name__ == 'dict'):
|
||||||
|
# XBMC JSON-RPC v6 returns an array object containing
|
||||||
|
# major, minor and patch number
|
||||||
|
xbmc_rpc_version = str(result['result']['version']['major'])
|
||||||
|
xbmc_rpc_version += '.' + str(result['result']['version']['minor'])
|
||||||
|
xbmc_rpc_version += '.' + str(result['result']['version']['patch'])
|
||||||
|
|
||||||
|
log.debug('XBMC JSON-RPC Version: %s', xbmc_rpc_version)
|
||||||
|
|
||||||
|
# ok, XBMC version is supported
|
||||||
|
self.use_json_notifications[host] = True
|
||||||
|
|
||||||
|
# send the text message
|
||||||
|
resp = self.request(host, [('GUI.ShowNotification', {'title':self.default_title, 'message':message, 'image':self.couch_logo_url})])
|
||||||
|
for result in resp:
|
||||||
|
if (result.get('result') and result['result'] == 'OK'):
|
||||||
|
log.debug('Message delivered successfully!')
|
||||||
|
success = True
|
||||||
|
break
|
||||||
|
elif (result.get('error')):
|
||||||
|
log.error('XBMC error; %s: %s (%s)', (result['id'], result['error']['message'], result['error']['code']))
|
||||||
|
break
|
||||||
|
|
||||||
|
# error getting version info (we do have contact with XBMC though)
|
||||||
|
elif (result.get('error')):
|
||||||
|
log.error('XBMC error; %s: %s (%s)', (result['id'], result['error']['message'], result['error']['code']))
|
||||||
|
|
||||||
|
log.debug('Use JSON notifications: %s ', self.use_json_notifications)
|
||||||
|
|
||||||
|
return success
|
||||||
|
|
||||||
|
def notifyXBMCnoJSON(self, host, data):
|
||||||
|
|
||||||
|
server = 'http://%s/xbmcCmds/' % host
|
||||||
|
|
||||||
|
# Notification(title, message [, timeout , image])
|
||||||
|
cmd = "xbmcHttp?command=ExecBuiltIn(Notification(%s,%s,'',%s))" % (urllib.quote(data['title']), urllib.quote(data['message']), urllib.quote(self.couch_logo_url))
|
||||||
|
server += cmd
|
||||||
|
|
||||||
|
# I have no idea what to set to, just tried text/plain and seems to be working :)
|
||||||
|
headers = {
|
||||||
|
'Content-Type': 'text/plain',
|
||||||
|
}
|
||||||
|
|
||||||
|
# authentication support
|
||||||
|
if self.conf('password'):
|
||||||
|
base64string = base64.encodestring('%s:%s' % (self.conf('username'), self.conf('password'))).replace('\n', '')
|
||||||
|
headers['Authorization'] = 'Basic %s' % base64string
|
||||||
|
|
||||||
|
try:
|
||||||
|
log.debug('Sending non-JSON-type request to %s: %s', (host, data))
|
||||||
|
|
||||||
|
# response wil either be 'OK':
|
||||||
|
# <html>
|
||||||
|
# <li>OK
|
||||||
|
# </html>
|
||||||
|
#
|
||||||
|
# or 'Error':
|
||||||
|
# <html>
|
||||||
|
# <li>Error:<message>
|
||||||
|
# </html>
|
||||||
|
#
|
||||||
|
response = self.urlopen(server, headers = headers)
|
||||||
|
|
||||||
|
if 'OK' in response:
|
||||||
|
log.debug('Returned from non-JSON-type request %s: %s', (host, response))
|
||||||
|
# manually fake expected response array
|
||||||
|
return [{'result': 'OK'}]
|
||||||
|
else:
|
||||||
|
log.error('Returned from non-JSON-type request %s: %s', (host, response))
|
||||||
|
# manually fake expected response array
|
||||||
|
return [{'result': 'Error'}]
|
||||||
|
|
||||||
|
except:
|
||||||
|
log.error('Failed sending non-JSON-type request to XBMC: %s', traceback.format_exc())
|
||||||
|
return [{'result': 'Error'}]
|
||||||
|
|
||||||
def request(self, host, requests):
|
def request(self, host, requests):
|
||||||
server = 'http://%s/jsonrpc' % host
|
server = 'http://%s/jsonrpc' % host
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class Plugin(object):
|
|||||||
self.makeDir(os.path.dirname(path))
|
self.makeDir(os.path.dirname(path))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
f = open(path, 'w' if not binary else 'wb')
|
f = open(path, 'w+' if not binary else 'w+b')
|
||||||
f.write(content)
|
f.write(content)
|
||||||
f.close()
|
f.close()
|
||||||
os.chmod(path, Env.getPermission('file'))
|
os.chmod(path, Env.getPermission('file'))
|
||||||
@@ -98,6 +98,7 @@ class Plugin(object):
|
|||||||
|
|
||||||
# http request
|
# http request
|
||||||
def urlopen(self, url, timeout = 30, params = None, headers = None, opener = None, multipart = False, show_error = True):
|
def urlopen(self, url, timeout = 30, params = None, headers = None, opener = None, multipart = False, show_error = True):
|
||||||
|
url = ss(url)
|
||||||
|
|
||||||
if not headers: headers = {}
|
if not headers: headers = {}
|
||||||
if not params: params = {}
|
if not params: params = {}
|
||||||
@@ -129,8 +130,11 @@ class Plugin(object):
|
|||||||
log.info('Opening multipart url: %s, params: %s', (url, [x for x in params.iterkeys()] if isinstance(params, dict) else 'with data'))
|
log.info('Opening multipart url: %s, params: %s', (url, [x for x in params.iterkeys()] if isinstance(params, dict) else 'with data'))
|
||||||
request = urllib2.Request(url, params, headers)
|
request = urllib2.Request(url, params, headers)
|
||||||
|
|
||||||
cookies = cookielib.CookieJar()
|
if opener:
|
||||||
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookies), MultipartPostHandler)
|
opener.add_handler(MultipartPostHandler())
|
||||||
|
else:
|
||||||
|
cookies = cookielib.CookieJar()
|
||||||
|
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookies), MultipartPostHandler)
|
||||||
|
|
||||||
response = opener.open(request, timeout = timeout)
|
response = opener.open(request, timeout = timeout)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -135,7 +135,6 @@ class Manage(Plugin):
|
|||||||
already_used = used_files.get(release_file['path'])
|
already_used = used_files.get(release_file['path'])
|
||||||
|
|
||||||
if already_used:
|
if already_used:
|
||||||
print already_used, release['id']
|
|
||||||
if already_used < release['id']:
|
if already_used < release['id']:
|
||||||
fireEvent('release.delete', release['id'], single = True) # delete this one
|
fireEvent('release.delete', release['id'], single = True) # delete this one
|
||||||
else:
|
else:
|
||||||
@@ -199,9 +198,12 @@ class Manage(Plugin):
|
|||||||
|
|
||||||
def directories(self):
|
def directories(self):
|
||||||
try:
|
try:
|
||||||
return splitString(self.conf('library', default = ''), '::')
|
if self.conf('library', '').strip():
|
||||||
|
return splitString(self.conf('library', default = ''), '::')
|
||||||
except:
|
except:
|
||||||
return []
|
pass
|
||||||
|
|
||||||
|
return []
|
||||||
|
|
||||||
def scanFilesToLibrary(self, folder = None, files = None):
|
def scanFilesToLibrary(self, folder = None, files = None):
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class Renamer(Plugin):
|
|||||||
addEvent('renamer.check_snatched', self.checkSnatched)
|
addEvent('renamer.check_snatched', self.checkSnatched)
|
||||||
|
|
||||||
addEvent('app.load', self.scan)
|
addEvent('app.load', self.scan)
|
||||||
|
addEvent('app.load', self.checkSnatched)
|
||||||
|
|
||||||
if self.conf('run_every') > 0:
|
if self.conf('run_every') > 0:
|
||||||
fireEvent('schedule.interval', 'renamer.check_snatched', self.checkSnatched, minutes = self.conf('run_every'))
|
fireEvent('schedule.interval', 'renamer.check_snatched', self.checkSnatched, minutes = self.conf('run_every'))
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class Scanner(Plugin):
|
|||||||
'()([ab])(\.....?)$' #*a.mkv
|
'()([ab])(\.....?)$' #*a.mkv
|
||||||
]
|
]
|
||||||
|
|
||||||
cp_imdb = '(\.cp\((?P<id>tt[0-9{7}]+)\))'
|
cp_imdb = '(.cp.(?P<id>tt[0-9{7}]+).)'
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
@@ -341,7 +341,7 @@ class Scanner(Plugin):
|
|||||||
group['files']['movie'] = self.getMediaFiles(group['unsorted_files'])
|
group['files']['movie'] = self.getMediaFiles(group['unsorted_files'])
|
||||||
|
|
||||||
if len(group['files']['movie']) == 0:
|
if len(group['files']['movie']) == 0:
|
||||||
log.error('Couldn\t find any movie files for %s', identifier)
|
log.error('Couldn\'t find any movie files for %s', identifier)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
log.debug('Getting metadata for %s', identifier)
|
log.debug('Getting metadata for %s', identifier)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ from couchpotato.environment import Env
|
|||||||
from inspect import ismethod, isfunction
|
from inspect import ismethod, isfunction
|
||||||
from sqlalchemy.exc import InterfaceError
|
from sqlalchemy.exc import InterfaceError
|
||||||
import datetime
|
import datetime
|
||||||
|
import random
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
@@ -83,37 +84,51 @@ class Searcher(Plugin):
|
|||||||
movies = db.query(Movie).filter(
|
movies = db.query(Movie).filter(
|
||||||
Movie.status.has(identifier = 'active')
|
Movie.status.has(identifier = 'active')
|
||||||
).all()
|
).all()
|
||||||
|
random.shuffle(movies)
|
||||||
|
|
||||||
self.in_progress = {
|
self.in_progress = {
|
||||||
'total': len(movies),
|
'total': len(movies),
|
||||||
'to_go': len(movies),
|
'to_go': len(movies),
|
||||||
}
|
}
|
||||||
|
|
||||||
for movie in movies:
|
try:
|
||||||
movie_dict = movie.to_dict({
|
search_types = self.getSearchTypes()
|
||||||
'profile': {'types': {'quality': {}}},
|
|
||||||
'releases': {'status': {}, 'quality': {}},
|
|
||||||
'library': {'titles': {}, 'files':{}},
|
|
||||||
'files': {}
|
|
||||||
})
|
|
||||||
|
|
||||||
try:
|
for movie in movies:
|
||||||
self.single(movie_dict)
|
movie_dict = movie.to_dict({
|
||||||
except IndexError:
|
'profile': {'types': {'quality': {}}},
|
||||||
log.error('Forcing library update for %s, if you see this often, please report: %s', (movie_dict['library']['identifier'], traceback.format_exc()))
|
'releases': {'status': {}, 'quality': {}},
|
||||||
fireEvent('library.update', movie_dict['library']['identifier'], force = True)
|
'library': {'titles': {}, 'files':{}},
|
||||||
except:
|
'files': {}
|
||||||
log.error('Search failed for %s: %s', (movie_dict['library']['identifier'], traceback.format_exc()))
|
})
|
||||||
|
|
||||||
self.in_progress['to_go'] -= 1
|
try:
|
||||||
|
self.single(movie_dict, search_types)
|
||||||
|
except IndexError:
|
||||||
|
log.error('Forcing library update for %s, if you see this often, please report: %s', (movie_dict['library']['identifier'], traceback.format_exc()))
|
||||||
|
fireEvent('library.update', movie_dict['library']['identifier'], force = True)
|
||||||
|
except:
|
||||||
|
log.error('Search failed for %s: %s', (movie_dict['library']['identifier'], traceback.format_exc()))
|
||||||
|
|
||||||
# Break if CP wants to shut down
|
self.in_progress['to_go'] -= 1
|
||||||
if self.shuttingDown():
|
|
||||||
break
|
# Break if CP wants to shut down
|
||||||
|
if self.shuttingDown():
|
||||||
|
break
|
||||||
|
|
||||||
|
except SearchSetupError:
|
||||||
|
pass
|
||||||
|
|
||||||
self.in_progress = False
|
self.in_progress = False
|
||||||
|
|
||||||
def single(self, movie):
|
def single(self, movie, search_types = None):
|
||||||
|
|
||||||
|
# Find out search type
|
||||||
|
try:
|
||||||
|
if not search_types:
|
||||||
|
search_types = self.getSearchTypes()
|
||||||
|
except SearchSetupError:
|
||||||
|
return
|
||||||
|
|
||||||
done_status = fireEvent('status.get', 'done', single = True)
|
done_status = fireEvent('status.get', 'done', single = True)
|
||||||
|
|
||||||
@@ -128,6 +143,8 @@ class Searcher(Plugin):
|
|||||||
available_status = fireEvent('status.get', 'available', single = True)
|
available_status = fireEvent('status.get', 'available', single = True)
|
||||||
ignored_status = fireEvent('status.get', 'ignored', single = True)
|
ignored_status = fireEvent('status.get', 'ignored', single = True)
|
||||||
|
|
||||||
|
found_releases = []
|
||||||
|
|
||||||
default_title = getTitle(movie['library'])
|
default_title = getTitle(movie['library'])
|
||||||
if not default_title:
|
if not default_title:
|
||||||
log.error('No proper info found for movie, removing it from library to cause it from having more issues.')
|
log.error('No proper info found for movie, removing it from library to cause it from having more issues.')
|
||||||
@@ -136,6 +153,7 @@ class Searcher(Plugin):
|
|||||||
|
|
||||||
fireEvent('notify.frontend', type = 'searcher.started.%s' % movie['id'], data = True, message = 'Searching for "%s"' % default_title)
|
fireEvent('notify.frontend', type = 'searcher.started.%s' % movie['id'], data = True, message = 'Searching for "%s"' % default_title)
|
||||||
|
|
||||||
|
|
||||||
ret = False
|
ret = False
|
||||||
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):
|
||||||
@@ -155,7 +173,11 @@ class Searcher(Plugin):
|
|||||||
log.info('Search for %s in %s', (default_title, quality_type['quality']['label']))
|
log.info('Search for %s in %s', (default_title, quality_type['quality']['label']))
|
||||||
quality = fireEvent('quality.single', identifier = quality_type['quality']['identifier'], single = True)
|
quality = fireEvent('quality.single', identifier = quality_type['quality']['identifier'], single = True)
|
||||||
|
|
||||||
results = fireEvent('yarr.search', movie, quality, merge = True)
|
results = []
|
||||||
|
for search_type in search_types:
|
||||||
|
type_results = fireEvent('%s.search' % search_type, movie, quality, merge = True)
|
||||||
|
if type_results:
|
||||||
|
results += type_results
|
||||||
|
|
||||||
sorted_results = sorted(results, key = lambda k: k['score'], reverse = True)
|
sorted_results = sorted(results, key = lambda k: k['score'], reverse = True)
|
||||||
if len(sorted_results) == 0:
|
if len(sorted_results) == 0:
|
||||||
@@ -172,10 +194,13 @@ class Searcher(Plugin):
|
|||||||
# Add them to this movie releases list
|
# Add them to this movie releases list
|
||||||
for nzb in sorted_results:
|
for nzb in sorted_results:
|
||||||
|
|
||||||
rls = db.query(Release).filter_by(identifier = md5(nzb['url'])).first()
|
nzb_identifier = md5(nzb['url'])
|
||||||
|
found_releases.append(nzb_identifier)
|
||||||
|
|
||||||
|
rls = db.query(Release).filter_by(identifier = nzb_identifier).first()
|
||||||
if not rls:
|
if not rls:
|
||||||
rls = Release(
|
rls = Release(
|
||||||
identifier = md5(nzb['url']),
|
identifier = nzb_identifier,
|
||||||
movie_id = movie.get('id'),
|
movie_id = movie.get('id'),
|
||||||
quality_id = quality_type.get('quality_id'),
|
quality_id = quality_type.get('quality_id'),
|
||||||
status_id = available_status.get('id')
|
status_id = available_status.get('id')
|
||||||
@@ -223,6 +248,12 @@ class Searcher(Plugin):
|
|||||||
break
|
break
|
||||||
elif downloaded != 'try_next':
|
elif downloaded != 'try_next':
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# Remove releases that aren't found anymore
|
||||||
|
for release in movie.get('releases', []):
|
||||||
|
if release.get('status_id') == available_status.get('id') and release.get('identifier') not in found_releases:
|
||||||
|
fireEvent('release.delete', release.get('id'), single = True)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
log.info('Better quality (%s) already available or snatched for %s', (quality_type['quality']['label'], default_title))
|
log.info('Better quality (%s) already available or snatched for %s', (quality_type['quality']['label'], default_title))
|
||||||
fireEvent('movie.restatus', movie['id'])
|
fireEvent('movie.restatus', movie['id'])
|
||||||
@@ -238,61 +269,87 @@ class Searcher(Plugin):
|
|||||||
|
|
||||||
def download(self, data, movie, manual = False):
|
def download(self, data, movie, manual = False):
|
||||||
|
|
||||||
snatched_status = fireEvent('status.get', 'snatched', single = True)
|
# Test to see if any downloaders are enabled for this type
|
||||||
|
downloader_enabled = fireEvent('download.enabled', manual, data, single = True)
|
||||||
|
|
||||||
# Download movie to temp
|
if downloader_enabled:
|
||||||
filedata = None
|
|
||||||
if data.get('download') and (ismethod(data.get('download')) or isfunction(data.get('download'))):
|
|
||||||
filedata = data.get('download')(url = data.get('url'), nzb_id = data.get('id'))
|
|
||||||
if filedata == 'try_next':
|
|
||||||
return filedata
|
|
||||||
|
|
||||||
successful = fireEvent('download', data = data, movie = movie, manual = manual, filedata = filedata, single = True)
|
snatched_status = fireEvent('status.get', 'snatched', single = True)
|
||||||
|
|
||||||
if successful:
|
# Download movie to temp
|
||||||
|
filedata = None
|
||||||
|
if data.get('download') and (ismethod(data.get('download')) or isfunction(data.get('download'))):
|
||||||
|
filedata = data.get('download')(url = data.get('url'), nzb_id = data.get('id'))
|
||||||
|
if filedata == 'try_next':
|
||||||
|
return filedata
|
||||||
|
|
||||||
try:
|
successful = fireEvent('download', data = data, movie = movie, manual = manual, filedata = filedata, single = True)
|
||||||
# Mark release as snatched
|
|
||||||
db = get_session()
|
|
||||||
rls = db.query(Release).filter_by(identifier = md5(data['url'])).first()
|
|
||||||
if rls:
|
|
||||||
rls.status_id = snatched_status.get('id')
|
|
||||||
db.commit()
|
|
||||||
|
|
||||||
log_movie = '%s (%s) in %s' % (getTitle(movie['library']), movie['library']['year'], rls.quality.label)
|
if successful:
|
||||||
snatch_message = 'Snatched "%s": %s' % (data.get('name'), log_movie)
|
|
||||||
log.info(snatch_message)
|
|
||||||
fireEvent('movie.snatched', message = snatch_message, data = rls.to_dict())
|
|
||||||
|
|
||||||
# If renamer isn't used, mark movie done
|
try:
|
||||||
if not Env.setting('enabled', 'renamer'):
|
# Mark release as snatched
|
||||||
active_status = fireEvent('status.get', 'active', single = True)
|
db = get_session()
|
||||||
done_status = fireEvent('status.get', 'done', single = True)
|
rls = db.query(Release).filter_by(identifier = md5(data['url'])).first()
|
||||||
try:
|
if rls:
|
||||||
if movie['status_id'] == active_status.get('id'):
|
rls.status_id = snatched_status.get('id')
|
||||||
for profile_type in movie['profile']['types']:
|
db.commit()
|
||||||
if rls and profile_type['quality_id'] == rls.quality.id and profile_type['finish']:
|
|
||||||
log.info('Renamer disabled, marking movie as finished: %s', log_movie)
|
|
||||||
|
|
||||||
# Mark release done
|
log_movie = '%s (%s) in %s' % (getTitle(movie['library']), movie['library']['year'], rls.quality.label)
|
||||||
rls.status_id = done_status.get('id')
|
snatch_message = 'Snatched "%s": %s' % (data.get('name'), log_movie)
|
||||||
db.commit()
|
log.info(snatch_message)
|
||||||
|
fireEvent('movie.snatched', message = snatch_message, data = rls.to_dict())
|
||||||
|
|
||||||
# Mark movie done
|
# If renamer isn't used, mark movie done
|
||||||
mvie = db.query(Movie).filter_by(id = movie['id']).first()
|
if not Env.setting('enabled', 'renamer'):
|
||||||
mvie.status_id = done_status.get('id')
|
active_status = fireEvent('status.get', 'active', single = True)
|
||||||
db.commit()
|
done_status = fireEvent('status.get', 'done', single = True)
|
||||||
except:
|
try:
|
||||||
log.error('Failed marking movie finished, renamer disabled: %s', traceback.format_exc())
|
if movie['status_id'] == active_status.get('id'):
|
||||||
|
for profile_type in movie['profile']['types']:
|
||||||
|
if rls and profile_type['quality_id'] == rls.quality.id and profile_type['finish']:
|
||||||
|
log.info('Renamer disabled, marking movie as finished: %s', log_movie)
|
||||||
|
|
||||||
except:
|
# Mark release done
|
||||||
log.error('Failed marking movie finished: %s', traceback.format_exc())
|
rls.status_id = done_status.get('id')
|
||||||
|
db.commit()
|
||||||
|
|
||||||
return True
|
# Mark movie done
|
||||||
|
mvie = db.query(Movie).filter_by(id = movie['id']).first()
|
||||||
|
mvie.status_id = done_status.get('id')
|
||||||
|
db.commit()
|
||||||
|
except:
|
||||||
|
log.error('Failed marking movie finished, renamer disabled: %s', traceback.format_exc())
|
||||||
|
|
||||||
|
except:
|
||||||
|
log.error('Failed marking movie finished: %s', traceback.format_exc())
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
log.info('Tried to download, but none of the "%s" downloaders are enabled', (data.get('type', '')))
|
||||||
|
|
||||||
log.info('Tried to download, but none of the downloaders are enabled')
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def getSearchTypes(self):
|
||||||
|
|
||||||
|
download_types = fireEvent('download.enabled_types', merge = True)
|
||||||
|
provider_types = fireEvent('provider.enabled_types', merge = True)
|
||||||
|
|
||||||
|
if download_types and len(list(set(provider_types) & set(download_types))) == 0:
|
||||||
|
log.error('There aren\'t any providers enabled for your downloader (%s). Check your settings.', ','.join(download_types))
|
||||||
|
raise NoProviders
|
||||||
|
|
||||||
|
for useless_provider in list(set(provider_types) - set(download_types)):
|
||||||
|
log.debug('Provider for "%s" enabled, but no downloader.', useless_provider)
|
||||||
|
|
||||||
|
search_types = download_types
|
||||||
|
|
||||||
|
if len(search_types) == 0:
|
||||||
|
log.error('There aren\'t any downloaders enabled. Please pick one in settings.')
|
||||||
|
raise NoDownloaders
|
||||||
|
|
||||||
|
return search_types
|
||||||
|
|
||||||
def correctMovie(self, nzb = {}, movie = {}, quality = {}, **kwargs):
|
def correctMovie(self, nzb = {}, movie = {}, quality = {}, **kwargs):
|
||||||
|
|
||||||
imdb_results = kwargs.get('imdb_results', False)
|
imdb_results = kwargs.get('imdb_results', False)
|
||||||
@@ -536,3 +593,12 @@ class Searcher(Plugin):
|
|||||||
except:
|
except:
|
||||||
log.error('Failed searching for next release: %s', traceback.format_exc())
|
log.error('Failed searching for next release: %s', traceback.format_exc())
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
class SearchSetupError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class NoDownloaders(SearchSetupError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class NoProviders(SearchSetupError):
|
||||||
|
pass
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ class Subtitle(Plugin):
|
|||||||
available_languages = sum(group['subtitle_language'].itervalues(), [])
|
available_languages = sum(group['subtitle_language'].itervalues(), [])
|
||||||
downloaded = []
|
downloaded = []
|
||||||
files = [toUnicode(x) for x in group['files']['movie']]
|
files = [toUnicode(x) for x in group['files']['movie']]
|
||||||
|
log.debug('Searching for subtitles for: %s', files)
|
||||||
|
|
||||||
for lang in self.getLanguages():
|
for lang in self.getLanguages():
|
||||||
if lang not in available_languages:
|
if lang not in available_languages:
|
||||||
@@ -57,6 +58,7 @@ class Subtitle(Plugin):
|
|||||||
downloaded.extend(download[subtitle])
|
downloaded.extend(download[subtitle])
|
||||||
|
|
||||||
for d_sub in downloaded:
|
for d_sub in downloaded:
|
||||||
|
log.info('Found subtitle (%s): %s', (d_sub.language.alpha2, files))
|
||||||
group['files']['subtitle'].add(d_sub.path)
|
group['files']['subtitle'].add(d_sub.path)
|
||||||
group['subtitle_language'][d_sub.path] = [d_sub.language.alpha2]
|
group['subtitle_language'][d_sub.path] = [d_sub.language.alpha2]
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
|
.page.wizard .uniForm {
|
||||||
|
width: 80%;
|
||||||
|
margin: 0 auto 30px;
|
||||||
|
}
|
||||||
|
|
||||||
.page.wizard h1 {
|
.page.wizard h1 {
|
||||||
padding: 10px 30px;
|
padding: 10px 30px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 40px;
|
font-size: 30px;
|
||||||
margin-top: 80px;
|
margin-top: 80px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ Page.Wizard = new Class({
|
|||||||
},
|
},
|
||||||
'providers': {
|
'providers': {
|
||||||
'title': 'Are you registered at any of these sites?',
|
'title': 'Are you registered at any of these sites?',
|
||||||
'description': 'CP uses these sites to search for movies. A few free are enabled by default, but it\'s always better to have a few more. Check settings for the full list of available providers.',
|
'description': 'CP uses these sites to search for movies. A few free are enabled by default, but it\'s always better to have a few more. Check settings for the full list of available providers.'
|
||||||
'include': ['nzb_providers', 'torrent_providers']
|
|
||||||
},
|
},
|
||||||
'renamer': {
|
'renamer': {
|
||||||
'title': 'Move & rename the movies after downloading?',
|
'title': 'Move & rename the movies after downloading?',
|
||||||
@@ -213,8 +212,6 @@ Page.Wizard = new Class({
|
|||||||
// Hide retention
|
// Hide retention
|
||||||
self.el.getElement('.tab_searcher').hide();
|
self.el.getElement('.tab_searcher').hide();
|
||||||
self.el.getElement('.t_searcher').hide();
|
self.el.getElement('.t_searcher').hide();
|
||||||
self.el.getElement('.t_nzb_providers').hide();
|
|
||||||
self.el.getElement('.t_torrent_providers').hide();
|
|
||||||
|
|
||||||
// Add pointer
|
// Add pointer
|
||||||
new Element('.tab_wrapper').wraps(tabs).adopt(
|
new Element('.tab_wrapper').wraps(tabs).adopt(
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
config = {
|
||||||
|
'name': 'automation_providers',
|
||||||
|
'groups': [
|
||||||
|
{
|
||||||
|
'label': 'Watchlists',
|
||||||
|
'description': 'Check watchlists for new movies',
|
||||||
|
'type': 'list',
|
||||||
|
'name': 'watchlist_providers',
|
||||||
|
'tab': 'automation',
|
||||||
|
'options': [],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'label': 'Automated',
|
||||||
|
'description': 'Uses minimal requirements',
|
||||||
|
'type': 'list',
|
||||||
|
'name': 'automation_providers',
|
||||||
|
'tab': 'automation',
|
||||||
|
'options': [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
from couchpotato.core.event import addEvent, fireEvent
|
from couchpotato.core.event import addEvent, fireEvent
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.plugins.base import Plugin
|
from couchpotato.core.providers.base import Provider
|
||||||
from couchpotato.environment import Env
|
from couchpotato.environment import Env
|
||||||
import time
|
import time
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Automation(Plugin):
|
class Automation(Provider):
|
||||||
|
|
||||||
enabled_option = 'automation_enabled'
|
enabled_option = 'automation_enabled'
|
||||||
|
|
||||||
@@ -19,6 +19,9 @@ class Automation(Plugin):
|
|||||||
|
|
||||||
def _getMovies(self):
|
def _getMovies(self):
|
||||||
|
|
||||||
|
if self.isDisabled():
|
||||||
|
return
|
||||||
|
|
||||||
if not self.canCheck():
|
if not self.canCheck():
|
||||||
log.debug('Just checked, skipping %s', self.getName())
|
log.debug('Just checked, skipping %s', self.getName())
|
||||||
return []
|
return []
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'automation',
|
'tab': 'automation',
|
||||||
|
'list': 'automation_providers',
|
||||||
'name': 'bluray_automation',
|
'name': 'bluray_automation',
|
||||||
'label': 'Blu-ray.com',
|
'label': 'Blu-ray.com',
|
||||||
'description': 'Imports movies from blu-ray.com. (uses minimal requirements)',
|
'description': 'Imports movies from blu-ray.com. (uses minimal requirements)',
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
from couchpotato.core.helpers.rss import RSS
|
from couchpotato.core.helpers.rss import RSS
|
||||||
from couchpotato.core.helpers.variable import md5, tryInt
|
from couchpotato.core.helpers.variable import tryInt
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.providers.automation.base import Automation
|
from couchpotato.core.providers.automation.base import Automation
|
||||||
import xml.etree.ElementTree as XMLTree
|
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
@@ -14,32 +13,24 @@ class Bluray(Automation, RSS):
|
|||||||
|
|
||||||
def getIMDBids(self):
|
def getIMDBids(self):
|
||||||
|
|
||||||
if self.isDisabled():
|
|
||||||
return
|
|
||||||
|
|
||||||
movies = []
|
movies = []
|
||||||
|
|
||||||
cache_key = 'bluray.%s' % md5(self.rss_url)
|
rss_movies = self.getRSSData(self.rss_url)
|
||||||
rss_data = self.getCache(cache_key, self.rss_url)
|
|
||||||
data = XMLTree.fromstring(rss_data)
|
|
||||||
|
|
||||||
if data is not None:
|
for movie in rss_movies:
|
||||||
rss_movies = self.getElements(data, 'channel/item')
|
name = self.getTextElement(movie, 'title').lower().split('blu-ray')[0].strip('(').rstrip()
|
||||||
|
year = self.getTextElement(movie, 'description').split('|')[1].strip('(').strip()
|
||||||
|
|
||||||
for movie in rss_movies:
|
if not name.find('/') == -1: # make sure it is not a double movie release
|
||||||
name = self.getTextElement(movie, "title").lower().split("blu-ray")[0].strip("(").rstrip()
|
continue
|
||||||
year = self.getTextElement(movie, "description").split("|")[1].strip("(").strip()
|
|
||||||
|
|
||||||
if not name.find("/") == -1: # make sure it is not a double movie release
|
if tryInt(year) < self.getMinimal('year'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if tryInt(year) < self.getMinimal('year'):
|
imdb = self.search(name, year)
|
||||||
continue
|
|
||||||
|
|
||||||
imdb = self.search(name, year)
|
if imdb:
|
||||||
|
if self.isMinimalMovie(imdb):
|
||||||
if imdb:
|
movies.append(imdb['imdb'])
|
||||||
if self.isMinimalMovie(imdb):
|
|
||||||
movies.append(imdb['imdb'])
|
|
||||||
|
|
||||||
return movies
|
return movies
|
||||||
|
|||||||
@@ -8,7 +8,4 @@ class CP(Automation):
|
|||||||
|
|
||||||
def getMovies(self):
|
def getMovies(self):
|
||||||
|
|
||||||
if self.isDisabled():
|
|
||||||
return
|
|
||||||
|
|
||||||
return []
|
return []
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'automation',
|
'tab': 'automation',
|
||||||
|
'list': 'watchlist_providers',
|
||||||
'name': 'imdb_automation',
|
'name': 'imdb_automation',
|
||||||
'label': 'IMDB',
|
'label': 'IMDB',
|
||||||
'description': 'From any <strong>public</strong> IMDB watchlists. Url should be the RSS link.',
|
'description': 'From any <strong>public</strong> IMDB watchlists. Url should be the RSS link.',
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from couchpotato.core.helpers.rss import RSS
|
from couchpotato.core.helpers.rss import RSS
|
||||||
from couchpotato.core.helpers.variable import md5, getImdb, splitString, tryInt
|
from couchpotato.core.helpers.variable import getImdb, splitString, tryInt
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.providers.automation.base import Automation
|
from couchpotato.core.providers.automation.base import Automation
|
||||||
import traceback
|
import traceback
|
||||||
@@ -13,9 +13,6 @@ class IMDB(Automation, RSS):
|
|||||||
|
|
||||||
def getIMDBids(self):
|
def getIMDBids(self):
|
||||||
|
|
||||||
if self.isDisabled():
|
|
||||||
return
|
|
||||||
|
|
||||||
movies = []
|
movies = []
|
||||||
|
|
||||||
enablers = [tryInt(x) for x in splitString(self.conf('automation_urls_use'))]
|
enablers = [tryInt(x) for x in splitString(self.conf('automation_urls_use'))]
|
||||||
@@ -29,9 +26,8 @@ class IMDB(Automation, RSS):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cache_key = 'imdb.rss.%s' % md5(url)
|
rss_data = self.getHTMLData(url)
|
||||||
rss_data = self.getCache(cache_key, url)
|
imdbs = getImdb(rss_data, multiple = True) if rss_data else []
|
||||||
imdbs = getImdb(rss_data, multiple = True)
|
|
||||||
|
|
||||||
for imdb in imdbs:
|
for imdb in imdbs:
|
||||||
movies.append(imdb)
|
movies.append(imdb)
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
from .main import ITunes
|
||||||
|
|
||||||
|
def start():
|
||||||
|
return ITunes()
|
||||||
|
|
||||||
|
config = [{
|
||||||
|
'name': 'itunes',
|
||||||
|
'groups': [
|
||||||
|
{
|
||||||
|
'tab': 'automation',
|
||||||
|
'list': 'automation_providers',
|
||||||
|
'name': 'itunes_automation',
|
||||||
|
'label': 'iTunes',
|
||||||
|
'description': 'From any <a href="http://itunes.apple.com/rss">iTunes</a> Store feed. Url should be the RSS link. (uses minimal requirements)',
|
||||||
|
'options': [
|
||||||
|
{
|
||||||
|
'name': 'automation_enabled',
|
||||||
|
'default': False,
|
||||||
|
'type': 'enabler',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'automation_urls_use',
|
||||||
|
'label': 'Use',
|
||||||
|
'default': ',',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'automation_urls',
|
||||||
|
'label': 'url',
|
||||||
|
'type': 'combined',
|
||||||
|
'combine': ['automation_urls_use', 'automation_urls'],
|
||||||
|
'default': 'https://itunes.apple.com/rss/topmovies/limit=25/xml,',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}]
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
from couchpotato.core.helpers.rss import RSS
|
||||||
|
from couchpotato.core.helpers.variable import md5, splitString, tryInt
|
||||||
|
from couchpotato.core.logger import CPLog
|
||||||
|
from couchpotato.core.providers.automation.base import Automation
|
||||||
|
from xml.etree.ElementTree import QName
|
||||||
|
import datetime
|
||||||
|
import traceback
|
||||||
|
import xml.etree.ElementTree as XMLTree
|
||||||
|
|
||||||
|
log = CPLog(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class ITunes(Automation, RSS):
|
||||||
|
|
||||||
|
interval = 1800
|
||||||
|
|
||||||
|
def getIMDBids(self):
|
||||||
|
|
||||||
|
if self.isDisabled():
|
||||||
|
return
|
||||||
|
|
||||||
|
movies = []
|
||||||
|
|
||||||
|
enablers = [tryInt(x) for x in splitString(self.conf('automation_urls_use'))]
|
||||||
|
urls = splitString(self.conf('automation_urls'))
|
||||||
|
|
||||||
|
namespace = 'http://www.w3.org/2005/Atom'
|
||||||
|
namespaceIM = 'http://itunes.apple.com/rss'
|
||||||
|
|
||||||
|
index = -1
|
||||||
|
for url in urls:
|
||||||
|
|
||||||
|
index += 1
|
||||||
|
if not enablers[index]:
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
cache_key = 'itunes.rss.%s' % md5(url)
|
||||||
|
rss_data = self.getCache(cache_key, url)
|
||||||
|
|
||||||
|
data = XMLTree.fromstring(rss_data)
|
||||||
|
|
||||||
|
if data is not None:
|
||||||
|
entry_tag = str(QName(namespace, 'entry'))
|
||||||
|
rss_movies = self.getElements(data, entry_tag)
|
||||||
|
|
||||||
|
for movie in rss_movies:
|
||||||
|
name_tag = str(QName(namespaceIM, 'name'))
|
||||||
|
name = self.getTextElement(movie, name_tag)
|
||||||
|
|
||||||
|
releaseDate_tag = str(QName(namespaceIM, 'releaseDate'))
|
||||||
|
releaseDateText = self.getTextElement(movie, releaseDate_tag)
|
||||||
|
year = datetime.datetime.strptime(releaseDateText, '%Y-%m-%dT00:00:00-07:00').strftime("%Y")
|
||||||
|
|
||||||
|
imdb = self.search(name, year)
|
||||||
|
|
||||||
|
if imdb and self.isMinimalMovie(imdb):
|
||||||
|
movies.append(imdb['imdb'])
|
||||||
|
|
||||||
|
except:
|
||||||
|
log.error('Failed loading iTunes rss feed: %s %s', (url, traceback.format_exc()))
|
||||||
|
|
||||||
|
return movies
|
||||||
@@ -8,6 +8,7 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'automation',
|
'tab': 'automation',
|
||||||
|
'list': 'automation_providers',
|
||||||
'name': 'kinepolis_automation',
|
'name': 'kinepolis_automation',
|
||||||
'label': 'Kinepolis',
|
'label': 'Kinepolis',
|
||||||
'description': 'Imports movies from the current top 10 of kinepolis. (uses minimal requirements)',
|
'description': 'Imports movies from the current top 10 of kinepolis. (uses minimal requirements)',
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
from couchpotato.core.helpers.rss import RSS
|
from couchpotato.core.helpers.rss import RSS
|
||||||
from couchpotato.core.helpers.variable import md5
|
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.providers.automation.base import Automation
|
from couchpotato.core.providers.automation.base import Automation
|
||||||
import datetime
|
import datetime
|
||||||
import xml.etree.ElementTree as XMLTree
|
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
@@ -15,25 +13,17 @@ class Kinepolis(Automation, RSS):
|
|||||||
|
|
||||||
def getIMDBids(self):
|
def getIMDBids(self):
|
||||||
|
|
||||||
if self.isDisabled():
|
|
||||||
return
|
|
||||||
|
|
||||||
movies = []
|
movies = []
|
||||||
|
|
||||||
cache_key = 'kinepolis.%s' % md5(self.rss_url)
|
rss_movies = self.getRSSData(self.rss_url)
|
||||||
rss_data = self.getCache(cache_key, self.rss_url)
|
|
||||||
data = XMLTree.fromstring(rss_data)
|
|
||||||
|
|
||||||
if data is not None:
|
for movie in rss_movies:
|
||||||
rss_movies = self.getElements(data, 'channel/item')
|
name = self.getTextElement(movie, 'title')
|
||||||
|
year = datetime.datetime.now().strftime('%Y')
|
||||||
|
|
||||||
for movie in rss_movies:
|
imdb = self.search(name, year)
|
||||||
name = self.getTextElement(movie, "title")
|
|
||||||
year = datetime.datetime.now().strftime("%Y")
|
|
||||||
|
|
||||||
imdb = self.search(name, year)
|
if imdb and self.isMinimalMovie(imdb):
|
||||||
|
movies.append(imdb['imdb'])
|
||||||
if imdb and self.isMinimalMovie(imdb):
|
|
||||||
movies.append(imdb['imdb'])
|
|
||||||
|
|
||||||
return movies
|
return movies
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
from .main import Moviemeter
|
||||||
|
|
||||||
|
def start():
|
||||||
|
return Moviemeter()
|
||||||
|
|
||||||
|
config = [{
|
||||||
|
'name': 'moviemeter',
|
||||||
|
'groups': [
|
||||||
|
{
|
||||||
|
'tab': 'automation',
|
||||||
|
'list': 'automation_providers',
|
||||||
|
'name': 'moviemeter_automation',
|
||||||
|
'label': 'Moviemeter',
|
||||||
|
'description': 'Imports movies from the current top 10 of moviemeter.nl. (uses minimal requirements)',
|
||||||
|
'options': [
|
||||||
|
{
|
||||||
|
'name': 'automation_enabled',
|
||||||
|
'default': False,
|
||||||
|
'type': 'enabler',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}]
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
from couchpotato.core.event import fireEvent
|
||||||
|
from couchpotato.core.helpers.rss import RSS
|
||||||
|
from couchpotato.core.logger import CPLog
|
||||||
|
from couchpotato.core.providers.automation.base import Automation
|
||||||
|
|
||||||
|
log = CPLog(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class Moviemeter(Automation, RSS):
|
||||||
|
|
||||||
|
interval = 1800
|
||||||
|
rss_url = 'http://www.moviemeter.nl/rss/cinema'
|
||||||
|
|
||||||
|
def getIMDBids(self):
|
||||||
|
|
||||||
|
movies = []
|
||||||
|
|
||||||
|
rss_movies = self.getRSSData(self.rss_url)
|
||||||
|
|
||||||
|
for movie in rss_movies:
|
||||||
|
|
||||||
|
name_year = fireEvent('scanner.name_year', self.getTextElement(movie, 'title'), single = True)
|
||||||
|
imdb = self.search(name_year.get('name'), name_year.get('year'))
|
||||||
|
|
||||||
|
if imdb and self.isMinimalMovie(imdb):
|
||||||
|
movies.append(imdb['imdb'])
|
||||||
|
|
||||||
|
return movies
|
||||||
@@ -8,6 +8,7 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'automation',
|
'tab': 'automation',
|
||||||
|
'list': 'watchlist_providers',
|
||||||
'name': 'moviesio',
|
'name': 'moviesio',
|
||||||
'label': 'Movies.IO',
|
'label': 'Movies.IO',
|
||||||
'description': 'Imports movies from <a href="http://movies.io">Movies.io</a> RSS watchlists',
|
'description': 'Imports movies from <a href="http://movies.io">Movies.io</a> RSS watchlists',
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
from couchpotato.core.event import fireEvent
|
from couchpotato.core.event import fireEvent
|
||||||
from couchpotato.core.helpers.rss import RSS
|
from couchpotato.core.helpers.rss import RSS
|
||||||
from couchpotato.core.helpers.variable import md5
|
from couchpotato.core.helpers.variable import tryInt, splitString
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.providers.automation.base import Automation
|
from couchpotato.core.providers.automation.base import Automation
|
||||||
from xml.etree.ElementTree import ParseError
|
|
||||||
import traceback
|
|
||||||
import xml.etree.ElementTree as XMLTree
|
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
@@ -16,39 +13,27 @@ class MoviesIO(Automation, RSS):
|
|||||||
|
|
||||||
def getIMDBids(self):
|
def getIMDBids(self):
|
||||||
|
|
||||||
if self.isDisabled():
|
|
||||||
return
|
|
||||||
|
|
||||||
movies = []
|
movies = []
|
||||||
|
|
||||||
enablers = self.conf('automation_urls_use').split(',')
|
enablers = [tryInt(x) for x in splitString(self.conf('automation_urls_use'))]
|
||||||
|
|
||||||
index = -1
|
index = -1
|
||||||
for rss_url in self.conf('automation_urls').split(','):
|
for rss_url in splitString(self.conf('automation_urls')):
|
||||||
|
|
||||||
index += 1
|
index += 1
|
||||||
if not enablers[index]:
|
if not enablers[index]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
rss_movies = self.getRSSData(rss_url, headers = {'Referer': ''})
|
||||||
cache_key = 'imdb.rss.%s' % md5(rss_url)
|
|
||||||
|
|
||||||
rss_data = self.getCache(cache_key, rss_url, headers = {'Referer': ''})
|
for movie in rss_movies:
|
||||||
data = XMLTree.fromstring(rss_data)
|
|
||||||
rss_movies = self.getElements(data, 'channel/item')
|
|
||||||
|
|
||||||
for movie in rss_movies:
|
nameyear = fireEvent('scanner.name_year', self.getTextElement(movie, 'title'), single = True)
|
||||||
|
imdb = self.search(nameyear.get('name'), nameyear.get('year'), imdb_only = True)
|
||||||
|
|
||||||
nameyear = fireEvent('scanner.name_year', self.getTextElement(movie, "title"), single = True)
|
if not imdb:
|
||||||
imdb = self.search(nameyear.get('name'), nameyear.get('year'), imdb_only = True)
|
continue
|
||||||
|
|
||||||
if not imdb:
|
movies.append(imdb)
|
||||||
continue
|
|
||||||
|
|
||||||
movies.append(imdb)
|
|
||||||
except ParseError:
|
|
||||||
log.debug('Failed loading Movies.io watchlist, probably empty: %s', (rss_url))
|
|
||||||
except:
|
|
||||||
log.error('Failed loading Movies.io watchlist: %s %s', (rss_url, traceback.format_exc()))
|
|
||||||
|
|
||||||
return movies
|
return movies
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
from .main import Rottentomatoes
|
||||||
|
|
||||||
|
def start():
|
||||||
|
return Rottentomatoes()
|
||||||
|
|
||||||
|
config = [{
|
||||||
|
'name': 'rottentomatoes',
|
||||||
|
'groups': [
|
||||||
|
{
|
||||||
|
'tab': 'automation',
|
||||||
|
'list': 'automation_providers',
|
||||||
|
'name': 'rottentomatoes_automation',
|
||||||
|
'label': 'Rottentomatoes',
|
||||||
|
'description': 'Imports movies from the rottentomatoes "in theaters"-feed.',
|
||||||
|
'options': [
|
||||||
|
{
|
||||||
|
'name': 'automation_enabled',
|
||||||
|
'default': False,
|
||||||
|
'type': 'enabler',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'tomatometer_percent',
|
||||||
|
'default': '80',
|
||||||
|
'label': 'Tomatometer'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}]
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
from couchpotato.core.helpers.rss import RSS
|
||||||
|
from couchpotato.core.helpers.variable import tryInt
|
||||||
|
from couchpotato.core.logger import CPLog
|
||||||
|
from couchpotato.core.providers.automation.base import Automation
|
||||||
|
from xml.etree.ElementTree import QName
|
||||||
|
import datetime
|
||||||
|
import re
|
||||||
|
|
||||||
|
log = CPLog(__name__)
|
||||||
|
|
||||||
|
class Rottentomatoes(Automation, RSS):
|
||||||
|
|
||||||
|
interval = 1800
|
||||||
|
urls = {
|
||||||
|
'namespace': 'http://www.rottentomatoes.com/xmlns/rtmovie/',
|
||||||
|
'theater': 'http://www.rottentomatoes.com/syndication/rss/in_theaters.xml',
|
||||||
|
}
|
||||||
|
|
||||||
|
def getIMDBids(self):
|
||||||
|
|
||||||
|
movies = []
|
||||||
|
|
||||||
|
rss_movies = self.getRSSData(self.urls['theater'])
|
||||||
|
rating_tag = str(QName(self.urls['namespace'], 'tomatometer_percent'))
|
||||||
|
|
||||||
|
for movie in rss_movies:
|
||||||
|
|
||||||
|
value = self.getTextElement(movie, "title")
|
||||||
|
result = re.search('(?<=%\s).*', value)
|
||||||
|
|
||||||
|
if result:
|
||||||
|
|
||||||
|
log.info2('Something smells...')
|
||||||
|
rating = tryInt(self.getTextElement(movie, rating_tag))
|
||||||
|
name = result.group(0)
|
||||||
|
|
||||||
|
if rating < tryInt(self.conf('tomatometer_percent')):
|
||||||
|
log.info2('%s seems to be rotten...' % name)
|
||||||
|
else:
|
||||||
|
|
||||||
|
log.info2('Found %s fresh enough movies, enqueuing: %s' % (rating, name))
|
||||||
|
year = datetime.datetime.now().strftime("%Y")
|
||||||
|
imdb = self.search(name, year)
|
||||||
|
|
||||||
|
if imdb:
|
||||||
|
movies.append(imdb['imdb'])
|
||||||
|
|
||||||
|
return movies
|
||||||
@@ -8,6 +8,7 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'automation',
|
'tab': 'automation',
|
||||||
|
'list': 'watchlist_providers',
|
||||||
'name': 'trakt_automation',
|
'name': 'trakt_automation',
|
||||||
'label': 'Trakt',
|
'label': 'Trakt',
|
||||||
'description': 'import movies from your own watchlist',
|
'description': 'import movies from your own watchlist',
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
from couchpotato.core.event import addEvent
|
from couchpotato.core.event import addEvent
|
||||||
from couchpotato.core.helpers.variable import md5, sha1
|
from couchpotato.core.helpers.variable import sha1
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.providers.automation.base import Automation
|
from couchpotato.core.providers.automation.base import Automation
|
||||||
import base64
|
import base64
|
||||||
import json
|
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
@@ -25,9 +24,6 @@ class Trakt(Automation):
|
|||||||
|
|
||||||
def getIMDBids(self):
|
def getIMDBids(self):
|
||||||
|
|
||||||
if self.isDisabled():
|
|
||||||
return
|
|
||||||
|
|
||||||
movies = []
|
movies = []
|
||||||
for movie in self.getWatchlist():
|
for movie in self.getWatchlist():
|
||||||
movies.append(movie.get('imdb_id'))
|
movies.append(movie.get('imdb_id'))
|
||||||
@@ -38,22 +34,11 @@ class Trakt(Automation):
|
|||||||
method = (self.urls['watchlist'] % self.conf('automation_api_key')) + self.conf('automation_username')
|
method = (self.urls['watchlist'] % self.conf('automation_api_key')) + self.conf('automation_username')
|
||||||
return self.call(method)
|
return self.call(method)
|
||||||
|
|
||||||
|
|
||||||
def call(self, method_url):
|
def call(self, method_url):
|
||||||
|
|
||||||
try:
|
headers = {}
|
||||||
if self.conf('automation_password'):
|
if self.conf('automation_password'):
|
||||||
headers = {
|
headers['Authorization'] = 'Basic %s' % base64.encodestring('%s:%s' % (self.conf('automation_username'), self.conf('automation_password')))[:-1]
|
||||||
'Authorization': 'Basic %s' % base64.encodestring('%s:%s' % (self.conf('automation_username'), self.conf('automation_password')))[:-1]
|
|
||||||
}
|
|
||||||
else:
|
|
||||||
headers = {}
|
|
||||||
|
|
||||||
cache_key = 'trakt.%s' % md5(method_url)
|
data = self.getJsonData(self.urls['base'] + method_url, headers = headers)
|
||||||
json_string = self.getCache(cache_key, self.urls['base'] + method_url, headers = headers)
|
return data if data else []
|
||||||
if json_string:
|
|
||||||
return json.loads(json_string)
|
|
||||||
except:
|
|
||||||
log.error('Failed to get data from trakt, check your login.')
|
|
||||||
|
|
||||||
return []
|
|
||||||
|
|||||||
@@ -44,6 +44,34 @@ class Provider(Plugin):
|
|||||||
|
|
||||||
return self.is_available.get(host, False)
|
return self.is_available.get(host, False)
|
||||||
|
|
||||||
|
def getJsonData(self, url, **kwargs):
|
||||||
|
|
||||||
|
data = self.getCache(md5(url), url, **kwargs)
|
||||||
|
|
||||||
|
if data:
|
||||||
|
try:
|
||||||
|
return json.loads(data)
|
||||||
|
except:
|
||||||
|
log.error('Failed to parsing %s: %s', (self.getName(), traceback.format_exc()))
|
||||||
|
|
||||||
|
return []
|
||||||
|
|
||||||
|
def getRSSData(self, url, item_path = 'channel/item', **kwargs):
|
||||||
|
|
||||||
|
data = self.getCache(md5(url), url, **kwargs)
|
||||||
|
|
||||||
|
if data:
|
||||||
|
try:
|
||||||
|
data = XMLTree.fromstring(data)
|
||||||
|
return self.getElements(data, item_path)
|
||||||
|
except:
|
||||||
|
log.error('Failed to parsing %s: %s', (self.getName(), traceback.format_exc()))
|
||||||
|
|
||||||
|
return []
|
||||||
|
|
||||||
|
def getHTMLData(self, url, **kwargs):
|
||||||
|
return self.getCache(md5(url), url, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class YarrProvider(Provider):
|
class YarrProvider(Provider):
|
||||||
|
|
||||||
@@ -56,8 +84,16 @@ class YarrProvider(Provider):
|
|||||||
login_opener = None
|
login_opener = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
addEvent('provider.enabled_types', self.getEnabledProviderType)
|
||||||
addEvent('provider.belongs_to', self.belongsTo)
|
addEvent('provider.belongs_to', self.belongsTo)
|
||||||
addEvent('yarr.search', self.search)
|
addEvent('yarr.search', self.search)
|
||||||
|
addEvent('%s.search' % self.type, self.search)
|
||||||
|
|
||||||
|
def getEnabledProviderType(self):
|
||||||
|
if self.isEnabled():
|
||||||
|
return self.type
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
|
|
||||||
@@ -67,15 +103,20 @@ class YarrProvider(Provider):
|
|||||||
urllib2.install_opener(opener)
|
urllib2.install_opener(opener)
|
||||||
log.info2('Logging into %s', self.urls['login'])
|
log.info2('Logging into %s', self.urls['login'])
|
||||||
f = opener.open(self.urls['login'], self.getLoginParams())
|
f = opener.open(self.urls['login'], self.getLoginParams())
|
||||||
f.read()
|
output = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
self.login_opener = opener
|
|
||||||
return True
|
if self.loginSuccess(output):
|
||||||
|
self.login_opener = opener
|
||||||
|
return True
|
||||||
except:
|
except:
|
||||||
log.error('Failed to login %s: %s', (self.getName(), traceback.format_exc()))
|
log.error('Failed to login %s: %s', (self.getName(), traceback.format_exc()))
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def loginSuccess(self, output):
|
||||||
|
return True
|
||||||
|
|
||||||
def loginDownload(self, url = '', nzb_id = ''):
|
def loginDownload(self, url = '', nzb_id = ''):
|
||||||
try:
|
try:
|
||||||
if not self.login_opener and not self.login():
|
if not self.login_opener and not self.login():
|
||||||
@@ -106,11 +147,11 @@ class YarrProvider(Provider):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
# Create result container
|
# Create result container
|
||||||
imdb_result = hasattr(self, '_search')
|
imdb_results = hasattr(self, '_search')
|
||||||
results = ResultList(self, movie, quality, imdb_result = imdb_result)
|
results = ResultList(self, movie, quality, imdb_results = imdb_results)
|
||||||
|
|
||||||
# Do search based on imdb id
|
# Do search based on imdb id
|
||||||
if imdb_result:
|
if imdb_results:
|
||||||
self._search(movie, quality, results)
|
self._search(movie, quality, results)
|
||||||
# Search possible titles
|
# Search possible titles
|
||||||
else:
|
else:
|
||||||
@@ -165,34 +206,6 @@ class YarrProvider(Provider):
|
|||||||
|
|
||||||
return [self.cat_backup_id]
|
return [self.cat_backup_id]
|
||||||
|
|
||||||
def getJsonData(self, url, **kwargs):
|
|
||||||
|
|
||||||
data = self.getCache(md5(url), url, **kwargs)
|
|
||||||
|
|
||||||
if data:
|
|
||||||
try:
|
|
||||||
return json.loads(data)
|
|
||||||
except:
|
|
||||||
log.error('Failed to parsing %s: %s', (self.getName(), traceback.format_exc()))
|
|
||||||
|
|
||||||
return []
|
|
||||||
|
|
||||||
def getRSSData(self, url, **kwargs):
|
|
||||||
|
|
||||||
data = self.getCache(md5(url), url, **kwargs)
|
|
||||||
|
|
||||||
if data:
|
|
||||||
try:
|
|
||||||
data = XMLTree.fromstring(data)
|
|
||||||
return self.getElements(data, 'channel/item')
|
|
||||||
except:
|
|
||||||
log.error('Failed to parsing %s: %s', (self.getName(), traceback.format_exc()))
|
|
||||||
|
|
||||||
return []
|
|
||||||
|
|
||||||
def getHTMLData(self, url, **kwargs):
|
|
||||||
return self.getCache(md5(url), url, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class ResultList(list):
|
class ResultList(list):
|
||||||
|
|
||||||
|
|||||||
@@ -30,11 +30,6 @@ class MovieResultModifier(Plugin):
|
|||||||
temp[imdb] = self.getLibraryTags(imdb)
|
temp[imdb] = self.getLibraryTags(imdb)
|
||||||
order.append(imdb)
|
order.append(imdb)
|
||||||
|
|
||||||
if item.get('via_imdb'):
|
|
||||||
if order.count(imdb):
|
|
||||||
order.remove(imdb)
|
|
||||||
order.insert(0, imdb)
|
|
||||||
|
|
||||||
# Merge dicts
|
# Merge dicts
|
||||||
temp[imdb] = mergeDicts(temp[imdb], item)
|
temp[imdb] = mergeDicts(temp[imdb], item)
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class CouchPotatoApi(MovieProvider):
|
|||||||
def search(self, q, limit = 12):
|
def search(self, q, limit = 12):
|
||||||
|
|
||||||
cache_key = 'cpapi.cache.%s' % q
|
cache_key = 'cpapi.cache.%s' % q
|
||||||
cached = self.getCache(cache_key, self.urls['search'] % tryUrlencode(q), timeout = 3, headers = self.getRequestHeaders())
|
cached = self.getCache(cache_key, self.urls['search'] % tryUrlencode(q), headers = self.getRequestHeaders())
|
||||||
|
|
||||||
if cached:
|
if cached:
|
||||||
try:
|
try:
|
||||||
@@ -50,7 +50,7 @@ class CouchPotatoApi(MovieProvider):
|
|||||||
return
|
return
|
||||||
|
|
||||||
cache_key = 'cpapi.cache.info.%s' % identifier
|
cache_key = 'cpapi.cache.info.%s' % identifier
|
||||||
cached = self.getCache(cache_key, self.urls['info'] % identifier, timeout = 3, headers = self.getRequestHeaders())
|
cached = self.getCache(cache_key, self.urls['info'] % identifier, headers = self.getRequestHeaders())
|
||||||
|
|
||||||
if cached:
|
if cached:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
from .main import IMDBAPI
|
|
||||||
|
|
||||||
def start():
|
|
||||||
return IMDBAPI()
|
|
||||||
|
|
||||||
config = []
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
from .main import OMDBAPI
|
||||||
|
|
||||||
|
def start():
|
||||||
|
return OMDBAPI()
|
||||||
|
|
||||||
|
config = []
|
||||||
+5
-5
@@ -10,11 +10,11 @@ import traceback
|
|||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
|
|
||||||
class IMDBAPI(MovieProvider):
|
class OMDBAPI(MovieProvider):
|
||||||
|
|
||||||
urls = {
|
urls = {
|
||||||
'search': 'http://www.imdbapi.com/?%s',
|
'search': 'http://www.omdbapi.com/?%s',
|
||||||
'info': 'http://www.imdbapi.com/?i=%s',
|
'info': 'http://www.omdbapi.com/?i=%s',
|
||||||
}
|
}
|
||||||
|
|
||||||
http_time_between_calls = 0
|
http_time_between_calls = 0
|
||||||
@@ -32,7 +32,7 @@ class IMDBAPI(MovieProvider):
|
|||||||
'name': q
|
'name': q
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_key = 'imdbapi.cache.%s' % q
|
cache_key = 'omdbapi.cache.%s' % q
|
||||||
cached = self.getCache(cache_key, self.urls['search'] % tryUrlencode({'t': name_year.get('name'), 'y': name_year.get('year', '')}), timeout = 3)
|
cached = self.getCache(cache_key, self.urls['search'] % tryUrlencode({'t': name_year.get('name'), 'y': name_year.get('year', '')}), timeout = 3)
|
||||||
|
|
||||||
if cached:
|
if cached:
|
||||||
@@ -50,7 +50,7 @@ class IMDBAPI(MovieProvider):
|
|||||||
if not identifier:
|
if not identifier:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
cache_key = 'imdbapi.cache.%s' % identifier
|
cache_key = 'omdbapi.cache.%s' % identifier
|
||||||
cached = self.getCache(cache_key, self.urls['info'] % identifier, timeout = 3)
|
cached = self.getCache(cache_key, self.urls['info'] % identifier, timeout = 3)
|
||||||
|
|
||||||
if cached:
|
if cached:
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
config = {
|
||||||
|
'name': 'nzb_providers',
|
||||||
|
'groups': [
|
||||||
|
{
|
||||||
|
'label': 'Usenet',
|
||||||
|
'description': 'Providers searching usenet for new releases',
|
||||||
|
'wizard': True,
|
||||||
|
'type': 'list',
|
||||||
|
'name': 'nzb_providers',
|
||||||
|
'tab': 'searcher',
|
||||||
|
'subtab': 'providers',
|
||||||
|
'options': [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'searcher',
|
'tab': 'searcher',
|
||||||
'subtab': 'nzb_providers',
|
'subtab': 'providers',
|
||||||
|
'list': 'nzb_providers',
|
||||||
'name': 'binsearch',
|
'name': 'binsearch',
|
||||||
'description': 'Free provider, less accurate. See <a href="https://www.binsearch.info/">BinSearch</a>',
|
'description': 'Free provider, less accurate. See <a href="https://www.binsearch.info/">BinSearch</a>',
|
||||||
|
'wizard': True,
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
'name': 'enabled',
|
'name': 'enabled',
|
||||||
|
|||||||
@@ -22,11 +22,10 @@ class BinSearch(NZBProvider):
|
|||||||
|
|
||||||
def _search(self, movie, quality, results):
|
def _search(self, movie, quality, results):
|
||||||
|
|
||||||
q = '%s %s' % (movie['library']['identifier'], quality.get('identifier'))
|
|
||||||
arguments = tryUrlencode({
|
arguments = tryUrlencode({
|
||||||
'q': q,
|
'q': movie['library']['identifier'],
|
||||||
'm': 'n',
|
'm': 'n',
|
||||||
'max': 250,
|
'max': 400,
|
||||||
'adv_age': Env.setting('retention', 'nzb'),
|
'adv_age': Env.setting('retention', 'nzb'),
|
||||||
'adv_sort': 'date',
|
'adv_sort': 'date',
|
||||||
'adv_col': 'on',
|
'adv_col': 'on',
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'searcher',
|
'tab': 'searcher',
|
||||||
'subtab': 'nzb_providers',
|
'subtab': 'providers',
|
||||||
|
'list': 'nzb_providers',
|
||||||
'name': 'FTDWorld',
|
'name': 'FTDWorld',
|
||||||
'description': 'Free provider, less accurate. See <a href="http://ftdworld.net">FTDWorld</a>',
|
'description': 'Free provider, less accurate. See <a href="http://ftdworld.net">FTDWorld</a>',
|
||||||
|
'wizard': True,
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
'name': 'enabled',
|
'name': 'enabled',
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
from bs4 import BeautifulSoup
|
|
||||||
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
|
||||||
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
|
||||||
from dateutil.parser import parse
|
from dateutil.parser import parse
|
||||||
import re
|
import json
|
||||||
import time
|
import traceback
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
@@ -14,10 +13,10 @@ log = CPLog(__name__)
|
|||||||
class FTDWorld(NZBProvider):
|
class FTDWorld(NZBProvider):
|
||||||
|
|
||||||
urls = {
|
urls = {
|
||||||
'search': 'http://ftdworld.net/category.php?%s',
|
'search': 'http://ftdworld.net/api/index.php?%s',
|
||||||
'detail': 'http://ftdworld.net/spotinfo.php?id=%s',
|
'detail': 'http://ftdworld.net/spotinfo.php?id=%s',
|
||||||
'download': 'http://ftdworld.net/cgi-bin/nzbdown.pl?fileID=%s',
|
'download': 'http://ftdworld.net/cgi-bin/nzbdown.pl?fileID=%s',
|
||||||
'login': 'http://ftdworld.net/index.php',
|
'login': 'http://ftdworld.net/api/login.php',
|
||||||
}
|
}
|
||||||
|
|
||||||
http_time_between_calls = 3 #seconds
|
http_time_between_calls = 3 #seconds
|
||||||
@@ -25,7 +24,7 @@ class FTDWorld(NZBProvider):
|
|||||||
cat_ids = [
|
cat_ids = [
|
||||||
([4, 11], ['dvdr']),
|
([4, 11], ['dvdr']),
|
||||||
([1], ['cam', 'ts', 'dvdrip', 'tc', 'r5', 'scr', 'brrip']),
|
([1], ['cam', 'ts', 'dvdrip', 'tc', 'r5', 'scr', 'brrip']),
|
||||||
([10, 13, 14], ['bd50', '720p', '1080p']),
|
([7, 10, 13, 14], ['bd50', '720p', '1080p']),
|
||||||
]
|
]
|
||||||
cat_backup_id = 1
|
cat_backup_id = 1
|
||||||
|
|
||||||
@@ -43,38 +42,30 @@ class FTDWorld(NZBProvider):
|
|||||||
'ctype': ','.join([str(x) for x in self.getCatId(quality['identifier'])]),
|
'ctype': ','.join([str(x) for x in self.getCatId(quality['identifier'])]),
|
||||||
})
|
})
|
||||||
|
|
||||||
data = self.getHTMLData(self.urls['search'] % params, opener = self.login_opener)
|
data = self.getJsonData(self.urls['search'] % params, opener = self.login_opener)
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
try:
|
try:
|
||||||
|
|
||||||
html = BeautifulSoup(data)
|
if data.get('numRes') == 0:
|
||||||
main_table = html.find('table', attrs = {'id':'ftdresult'})
|
|
||||||
|
|
||||||
if not main_table:
|
|
||||||
return
|
return
|
||||||
|
|
||||||
items = main_table.find_all('tr', attrs = {'class': re.compile('tcontent')})
|
for item in data.get('data'):
|
||||||
|
|
||||||
for item in items:
|
|
||||||
tds = item.find_all('td')
|
|
||||||
nzb_id = tryInt(item.attrs['data-spot'])
|
|
||||||
|
|
||||||
up = item.find('img', attrs = {'src': re.compile('up.png')})
|
|
||||||
down = item.find('img', attrs = {'src': re.compile('down.png')})
|
|
||||||
|
|
||||||
|
nzb_id = tryInt(item.get('id'))
|
||||||
results.append({
|
results.append({
|
||||||
'id': nzb_id,
|
'id': nzb_id,
|
||||||
'name': toUnicode(item.find('a', attrs = {'href': re.compile('./spotinfo')}).text.strip()),
|
'name': toUnicode(item.get('Title')),
|
||||||
'age': self.calculateAge(int(time.mktime(parse(tds[2].text).timetuple()))),
|
'age': self.calculateAge(tryInt(item.get('Created'))),
|
||||||
|
'size': item.get('Size', 0),
|
||||||
'url': self.urls['download'] % nzb_id,
|
'url': self.urls['download'] % nzb_id,
|
||||||
'download': self.loginDownload,
|
'download': self.loginDownload,
|
||||||
'detail_url': self.urls['detail'] % nzb_id,
|
'detail_url': self.urls['detail'] % nzb_id,
|
||||||
'score': (tryInt(up.attrs['title'].split(' ')[0]) * 3) - (tryInt(down.attrs['title'].split(' ')[0]) * 3) if up else 0,
|
'score': (tryInt(item.get('webPlus', 0)) - tryInt(item.get('webMin', 0))) * 3,
|
||||||
})
|
})
|
||||||
|
|
||||||
except:
|
except:
|
||||||
log.error('Failed to parse HTML response from FTDWorld')
|
log.error('Failed to parse HTML response from FTDWorld: %s', traceback.format_exc())
|
||||||
|
|
||||||
def getLoginParams(self):
|
def getLoginParams(self):
|
||||||
return tryUrlencode({
|
return tryUrlencode({
|
||||||
@@ -82,3 +73,9 @@ class FTDWorld(NZBProvider):
|
|||||||
'passlogin': self.conf('password'),
|
'passlogin': self.conf('password'),
|
||||||
'submit': 'Log In',
|
'submit': 'Log In',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def loginSuccess(self, output):
|
||||||
|
try:
|
||||||
|
return json.loads(output).get('goodToGo', False)
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|||||||
@@ -8,12 +8,13 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'searcher',
|
'tab': 'searcher',
|
||||||
'subtab': 'nzb_providers',
|
'subtab': 'providers',
|
||||||
|
'list': 'nzb_providers',
|
||||||
'name': 'newznab',
|
'name': 'newznab',
|
||||||
'order': 10,
|
'order': 10,
|
||||||
'description': 'Enable <a href="http://newznab.com/" target="_blank">NewzNab providers</a> such as <a href="https://nzb.su" target="_blank">NZB.su</a>, \
|
'description': 'Enable <a href="http://newznab.com/" target="_blank">NewzNab providers</a> such as <a href="https://nzb.su" target="_blank">NZB.su</a>, \
|
||||||
<a href="https://nzbs.org" target="_blank">NZBs.org</a>, <a href="http://dognzb.cr/" target="_blank">DOGnzb.cr</a>, \
|
<a href="https://nzbs.org" target="_blank">NZBs.org</a>, <a href="http://dognzb.cr/" target="_blank">DOGnzb.cr</a>, \
|
||||||
<a href="https://github.com/spotweb/spotweb" target="_blank">Spotweb</a>',
|
<a href="https://github.com/spotweb/spotweb" target="_blank">Spotweb</a> or <a href="https://nzbgeek.info/" target="_blank">NZBGeek</a>',
|
||||||
'wizard': True,
|
'wizard': True,
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
@@ -22,16 +23,16 @@ config = [{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'use',
|
'name': 'use',
|
||||||
'default': '0,0,0'
|
'default': '0,0,0,0'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'host',
|
'name': 'host',
|
||||||
'default': 'nzb.su,dognzb.cr,nzbs.org',
|
'default': 'nzb.su,dognzb.cr,nzbs.org,https://index.nzbgeek.info',
|
||||||
'description': 'The hostname of your newznab provider',
|
'description': 'The hostname of your newznab provider',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'api_key',
|
'name': 'api_key',
|
||||||
'default': ',,',
|
'default': ',,,',
|
||||||
'label': 'Api Key',
|
'label': 'Api Key',
|
||||||
'description': 'Can be found on your profile page',
|
'description': 'Can be found on your profile page',
|
||||||
'type': 'combined',
|
'type': 'combined',
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class Newznab(NZBProvider, RSS):
|
|||||||
def search(self, movie, quality):
|
def search(self, movie, quality):
|
||||||
hosts = self.getHosts()
|
hosts = self.getHosts()
|
||||||
|
|
||||||
results = ResultList(self, movie, quality, imdb_result = True)
|
results = ResultList(self, movie, quality, imdb_results = True)
|
||||||
|
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
if self.isDisabled(host):
|
if self.isDisabled(host):
|
||||||
@@ -73,8 +73,8 @@ class Newznab(NZBProvider, RSS):
|
|||||||
'name': self.getTextElement(nzb, 'title'),
|
'name': self.getTextElement(nzb, 'title'),
|
||||||
'age': self.calculateAge(int(time.mktime(parse(date).timetuple()))),
|
'age': self.calculateAge(int(time.mktime(parse(date).timetuple()))),
|
||||||
'size': int(self.getElement(nzb, 'enclosure').attrib['length']) / 1024 / 1024,
|
'size': int(self.getElement(nzb, 'enclosure').attrib['length']) / 1024 / 1024,
|
||||||
'url': (self.getUrl(host['host'], self.urls['download']) % nzb_id) + self.getApiExt(host),
|
'url': (self.getUrl(host['host'], self.urls['download']) % tryUrlencode(nzb_id)) + self.getApiExt(host),
|
||||||
'detail_url': '%sdetails/%s' % (cleanHost(host['host']), nzb_id),
|
'detail_url': '%sdetails/%s' % (cleanHost(host['host']), tryUrlencode(nzb_id)),
|
||||||
'content': self.getTextElement(nzb, 'description'),
|
'content': self.getTextElement(nzb, 'description'),
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -104,12 +104,23 @@ class Newznab(NZBProvider, RSS):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def getUrl(self, host, type):
|
def getUrl(self, host, type):
|
||||||
|
if '?page=newznabapi' in host:
|
||||||
|
return cleanHost(host)[:-1] + '&t=' + type
|
||||||
|
|
||||||
return cleanHost(host) + 'api?t=' + type
|
return cleanHost(host) + 'api?t=' + type
|
||||||
|
|
||||||
def isDisabled(self, host):
|
def isDisabled(self, host = None):
|
||||||
return not self.isEnabled(host)
|
return not self.isEnabled(host)
|
||||||
|
|
||||||
def isEnabled(self, host):
|
def isEnabled(self, host = None):
|
||||||
|
|
||||||
|
# Return true if at least one is enabled and no host is given
|
||||||
|
if host is None:
|
||||||
|
for host in self.getHosts():
|
||||||
|
if self.isEnabled(host):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
return NZBProvider.isEnabled(self) and host['host'] and host['api_key'] and int(host['use'])
|
return NZBProvider.isEnabled(self) and host['host'] and host['api_key'] and int(host['use'])
|
||||||
|
|
||||||
def getApiExt(self, host):
|
def getApiExt(self, host):
|
||||||
@@ -136,6 +147,6 @@ class Newznab(NZBProvider, RSS):
|
|||||||
self.limits_reached[host] = time.time()
|
self.limits_reached[host] = time.time()
|
||||||
return 'try_next'
|
return 'try_next'
|
||||||
|
|
||||||
log.error('Failed download from %s', (host, traceback.format_exc()))
|
log.error('Failed download from %s: %s', (host, traceback.format_exc()))
|
||||||
|
|
||||||
return 'try_next'
|
return 'try_next'
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'searcher',
|
'tab': 'searcher',
|
||||||
'subtab': 'nzb_providers',
|
'subtab': 'providers',
|
||||||
|
'list': 'nzb_providers',
|
||||||
'name': 'NZBClub',
|
'name': 'NZBClub',
|
||||||
'description': 'Free provider, less accurate. See <a href="https://www.nzbclub.com/">NZBClub</a>',
|
'description': 'Free provider, less accurate. See <a href="https://www.nzbclub.com/">NZBClub</a>',
|
||||||
|
'wizard': True,
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
'name': 'enabled',
|
'name': 'enabled',
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ class NZBClub(NZBProvider, RSS):
|
|||||||
|
|
||||||
def _searchOnTitle(self, title, movie, quality, results):
|
def _searchOnTitle(self, title, movie, quality, results):
|
||||||
|
|
||||||
q = '"%s %s" %s' % (title, movie['library']['year'], quality.get('identifier'))
|
q = '"%s %s"' % (title, movie['library']['year'])
|
||||||
|
|
||||||
params = tryUrlencode({
|
params = tryUrlencode({
|
||||||
'q': q,
|
'q': q,
|
||||||
'ig': '1',
|
'ig': 1,
|
||||||
'rpp': 200,
|
'rpp': 200,
|
||||||
'st': 1,
|
'st': 5,
|
||||||
'sp': 1,
|
'sp': 1,
|
||||||
'ns': 1,
|
'ns': 1,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'searcher',
|
'tab': 'searcher',
|
||||||
'subtab': 'nzb_providers',
|
'subtab': 'providers',
|
||||||
|
'list': 'nzb_providers',
|
||||||
'name': 'nzbindex',
|
'name': 'nzbindex',
|
||||||
'description': 'Free provider, less accurate. See <a href="https://www.nzbindex.com/">NZBIndex</a>',
|
'description': 'Free provider, less accurate. See <a href="https://www.nzbindex.com/">NZBIndex</a>',
|
||||||
|
'wizard': True,
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
'name': 'enabled',
|
'name': 'enabled',
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class NzbIndex(NZBProvider, RSS):
|
|||||||
|
|
||||||
def _searchOnTitle(self, title, movie, quality, results):
|
def _searchOnTitle(self, title, movie, quality, results):
|
||||||
|
|
||||||
q = '"%s" %s %s' % (title, movie['library']['year'], quality.get('identifier'))
|
q = '"%s %s"' % (title, movie['library']['year'])
|
||||||
arguments = tryUrlencode({
|
arguments = tryUrlencode({
|
||||||
'q': q,
|
'q': q,
|
||||||
'age': Env.setting('retention', 'nzb'),
|
'age': Env.setting('retention', 'nzb'),
|
||||||
|
|||||||
@@ -8,10 +8,11 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'searcher',
|
'tab': 'searcher',
|
||||||
'subtab': 'nzb_providers',
|
'subtab': 'providers',
|
||||||
|
'list': 'nzb_providers',
|
||||||
'name': 'nzbsrus',
|
'name': 'nzbsrus',
|
||||||
'label': 'Nzbsrus',
|
'label': 'Nzbsrus',
|
||||||
'description': 'See <a href="https://www.nzbsrus.com/">NZBsRus</a>',
|
'description': 'See <a href="https://www.nzbsrus.com/">NZBsRus</a>. <strong>You need a VIP account!</strong>',
|
||||||
'wizard': True,
|
'wizard': True,
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class Nzbsrus(NZBProvider, RSS):
|
|||||||
arguments += '&lang0=1&lang3=1&lang1=1'
|
arguments += '&lang0=1&lang3=1&lang1=1'
|
||||||
|
|
||||||
url = '%s&%s&%s' % (self.urls['search'], arguments , cat_id_string)
|
url = '%s&%s&%s' % (self.urls['search'], arguments , cat_id_string)
|
||||||
nzbs = self.getRSSData(url, cache_timeout = 1800, headers = {'User-Agent': Env.getIdentifier()})
|
nzbs = self.getRSSData(url, item_path = 'results/result', cache_timeout = 1800, headers = {'User-Agent': Env.getIdentifier()})
|
||||||
|
|
||||||
for nzb in nzbs:
|
for nzb in nzbs:
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ class Nzbsrus(NZBProvider, RSS):
|
|||||||
'name': title,
|
'name': title,
|
||||||
'age': age,
|
'age': age,
|
||||||
'size': size,
|
'size': size,
|
||||||
'url': self.urls['download'] % id + self.getApiExt() + self.getTextElement(nzb, 'key'),
|
'url': self.urls['download'] % nzb_id + self.getApiExt() + self.getTextElement(nzb, 'key'),
|
||||||
'detail_url': self.urls['detail'] % nzb_id,
|
'detail_url': self.urls['detail'] % nzb_id,
|
||||||
'description': self.getTextElement(nzb, 'addtext'),
|
'description': self.getTextElement(nzb, 'addtext'),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'searcher',
|
'tab': 'searcher',
|
||||||
'subtab': 'nzb_providers',
|
'subtab': 'providers',
|
||||||
|
'list': 'nzb_providers',
|
||||||
'name': 'nzbX',
|
'name': 'nzbX',
|
||||||
'description': 'Free provider, less accurate. See <a href="https://www.nzbx.co/">nzbX</a>',
|
'description': 'Free provider. See <a href="https://www.nzbx.co/">nzbX</a>',
|
||||||
|
'wizard': True,
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
'name': 'enabled',
|
'name': 'enabled',
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ from couchpotato.core.helpers.encoding import tryUrlencode
|
|||||||
from couchpotato.core.helpers.variable import tryInt
|
from couchpotato.core.helpers.variable import tryInt
|
||||||
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
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
@@ -22,7 +23,7 @@ class Nzbx(NZBProvider):
|
|||||||
'q': movie['library']['identifier'].replace('tt', ''),
|
'q': movie['library']['identifier'].replace('tt', ''),
|
||||||
'sf': quality.get('size_min'),
|
'sf': quality.get('size_min'),
|
||||||
})
|
})
|
||||||
nzbs = self.getJsonData(self.urls['search'] % arguments)
|
nzbs = self.getJsonData(self.urls['search'] % arguments, headers = {'User-Agent': Env.getIdentifier()})
|
||||||
|
|
||||||
for nzb in nzbs:
|
for nzb in nzbs:
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'searcher',
|
'tab': 'searcher',
|
||||||
'subtab': 'nzb_providers',
|
'subtab': 'providers',
|
||||||
|
'list': 'nzb_providers',
|
||||||
'name': 'OMGWTFNZBs',
|
'name': 'OMGWTFNZBs',
|
||||||
'description': 'See <a href="http://www.omgwtfnzbs.com/">OMGWTFNZBs</a>',
|
'description': 'See <a href="http://omgwtfnzbs.org/">OMGWTFNZBs</a>',
|
||||||
|
'wizard': True,
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
'name': 'enabled',
|
'name': 'enabled',
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ log = CPLog(__name__)
|
|||||||
class OMGWTFNZBs(NZBProvider, RSS):
|
class OMGWTFNZBs(NZBProvider, RSS):
|
||||||
|
|
||||||
urls = {
|
urls = {
|
||||||
'search': 'http://rss.omgwtfnzbs.com/rss-search.php?%s',
|
'search': 'http://rss.omgwtfnzbs.org/rss-search.php?%s',
|
||||||
}
|
}
|
||||||
|
|
||||||
http_time_between_calls = 1 #seconds
|
http_time_between_calls = 1 #seconds
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
config = {
|
||||||
|
'name': 'torrent_providers',
|
||||||
|
'groups': [
|
||||||
|
{
|
||||||
|
'label': 'Torrent',
|
||||||
|
'description': 'Providers searching torrent sites for new releases',
|
||||||
|
'wizard': True,
|
||||||
|
'type': 'list',
|
||||||
|
'name': 'torrent_providers',
|
||||||
|
'tab': 'searcher',
|
||||||
|
'subtab': 'providers',
|
||||||
|
'options': [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'searcher',
|
'tab': 'searcher',
|
||||||
'subtab': 'torrent_providers',
|
'subtab': 'providers',
|
||||||
|
'list': 'torrent_providers',
|
||||||
'name': 'KickAssTorrents',
|
'name': 'KickAssTorrents',
|
||||||
'description': 'See <a href="https://kat.ph/">KickAssTorrents</a>',
|
'description': 'See <a href="https://kat.ph/">KickAssTorrents</a>',
|
||||||
'wizard': True,
|
'wizard': True,
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'searcher',
|
'tab': 'searcher',
|
||||||
'subtab': 'torrent_providers',
|
'subtab': 'providers',
|
||||||
|
'list': 'torrent_providers',
|
||||||
'name': 'PassThePopcorn',
|
'name': 'PassThePopcorn',
|
||||||
'description': 'See <a href="https://passthepopcorn.me">PassThePopcorn.me</a>',
|
'description': 'See <a href="https://passthepopcorn.me">PassThePopcorn.me</a>',
|
||||||
|
'wizard': True,
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
'name': 'enabled',
|
'name': 'enabled',
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'searcher',
|
'tab': 'searcher',
|
||||||
'subtab': 'torrent_providers',
|
'subtab': 'providers',
|
||||||
|
'list': 'torrent_providers',
|
||||||
'name': 'PublicHD',
|
'name': 'PublicHD',
|
||||||
'description': 'Public Torrent site with only HD content. See <a href="https://publichd.se/">PublicHD</a>',
|
'description': 'Public Torrent site with only HD content. See <a href="https://publichd.se/">PublicHD</a>',
|
||||||
|
'wizard': True,
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
'name': 'enabled',
|
'name': 'enabled',
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ config = [{
|
|||||||
'groups': [
|
'groups': [
|
||||||
{
|
{
|
||||||
'tab': 'searcher',
|
'tab': 'searcher',
|
||||||
'subtab': 'torrent_providers',
|
'subtab': 'providers',
|
||||||
|
'list': 'torrent_providers',
|
||||||
'name': 'SceneAccess',
|
'name': 'SceneAccess',
|
||||||
'description': 'See <a href="https://sceneaccess.eu/">SceneAccess</a>',
|
'description': 'See <a href="https://sceneaccess.eu/">SceneAccess</a>',
|
||||||
|
'wizard': True,
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
'name': 'enabled',
|
'name': 'enabled',
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user