2 changed files with 94 additions and 0 deletions
@ -0,0 +1,37 @@ |
|||
from .main import Pneumatic |
|||
|
|||
def start(): |
|||
return Pneumatic() |
|||
|
|||
config = [{ |
|||
'name': 'pneumatic', |
|||
'order': 30, |
|||
'groups': [ |
|||
{ |
|||
'tab': 'downloaders', |
|||
'name': 'pneumatic', |
|||
'label': 'Pneumatic', |
|||
'description': 'Download the .strm file to a specific folder.', |
|||
'wizard': True, |
|||
'options': [ |
|||
{ |
|||
'name': 'enabled', |
|||
'default': 0, |
|||
'type': 'enabler', |
|||
}, |
|||
{ |
|||
'name': 'directory', |
|||
'type': 'directory', |
|||
'description': 'Directory where the .strm file is saved to.', |
|||
}, |
|||
{ |
|||
'name': 'manual', |
|||
'default': 0, |
|||
'type': 'bool', |
|||
'advanced': True, |
|||
'description': 'Disable this downloader for automated searches, but use it when I manually send a release.', |
|||
}, |
|||
], |
|||
} |
|||
], |
|||
}] |
@ -0,0 +1,57 @@ |
|||
from __future__ import with_statement |
|||
from couchpotato.core.downloaders.base import Downloader |
|||
from couchpotato.core.logger import CPLog |
|||
import os |
|||
import traceback |
|||
import sys |
|||
|
|||
log = CPLog(__name__) |
|||
|
|||
class Pneumatic(Downloader): |
|||
|
|||
type = ['nzb'] |
|||
strm_syntax = 'plugin://plugin.program.pneumatic/?mode=strm&type=add_file&nzb=%s&nzbname=%s' |
|||
|
|||
def download(self, data = {}, movie = {}, manual = False, filedata = None): |
|||
if self.isDisabled(manual) or (not self.isCorrectType(data.get('type'))): |
|||
return |
|||
|
|||
directory = self.conf('directory') |
|||
if not directory or not os.path.isdir(directory): |
|||
log.error('No directory set for .strm downloads.') |
|||
else: |
|||
try: |
|||
if not filedata or len(filedata) < 50: |
|||
log.error('No nzb available!') |
|||
return False |
|||
|
|||
fullPath = os.path.join(directory, self.createFileName(data, filedata, movie)) |
|||
|
|||
try: |
|||
if not os.path.isfile(fullPath): |
|||
log.info('Downloading %s to %s.', (data.get('type'), fullPath)) |
|||
with open(fullPath, 'wb') as f: |
|||
f.write(filedata) |
|||
|
|||
nzb_name = self.createNzbName(data, movie) |
|||
strm_path = os.path.join(directory, nzb_name) |
|||
|
|||
strm_file = open(strm_path + '.strm', 'wb') |
|||
strmContent = self.strm_syntax % (fullPath, nzb_name) |
|||
strm_file.write(strmContent) |
|||
strm_file.close() |
|||
|
|||
return True |
|||
|
|||
else: |
|||
log.info('File %s already exists.', fullPath) |
|||
return True |
|||
|
|||
except: |
|||
log.error('Failed to download .strm: %s', traceback.format_exc()) |
|||
pass |
|||
|
|||
except: |
|||
log.info('Failed to download file %s: %s', (data.get('name'), traceback.format_exc())) |
|||
return False |
|||
return False |
Loading…
Reference in new issue