Browse Source

Add support for processing .nzb.bz2 files.

Support the BZIP2 format.
pull/246/merge
shypike 10 years ago
parent
commit
548f448b9d
  1. 4
      SABnzbd.py
  2. 2
      sabnzbd/api.py
  3. 13
      sabnzbd/dirscanner.py
  4. 2
      sabnzbd/osxmenu.py
  5. 3
      sabnzbd/sabtraylinux.py
  6. 4
      sabnzbd/skintext.py
  7. 2
      sabnzbd/urlgrabber.py
  8. 2
      sabnzbd/utils/upload.py

4
SABnzbd.py

@ -859,7 +859,7 @@ def commandline_handler(frozen=True):
if not service:
# Get and remove any NZB file names
for entry in args:
if get_ext(entry) in ('.nzb', '.zip','.rar', '.gz'):
if get_ext(entry) in ('.nzb', '.zip','.rar', '.gz', '.bz2'):
upload_nzbs.append(os.path.abspath(entry))
for opt, arg in opts:
@ -1599,7 +1599,7 @@ def main():
logging.exception("Failed to start %s-%s", sabnzbd.MY_NAME, sabnzbd.__version__)
sabnzbd.halt()
# Upload any nzb/zip/rar/nzb.gz files from file association
# Upload any nzb/zip/rar/nzb.gz/nzb.bz2 files from file association
if upload_nzbs:
from sabnzbd.utils.upload import add_local
for f in upload_nzbs:

2
sabnzbd/api.py

@ -380,7 +380,7 @@ def _api_addlocalfile(name, output, kwargs):
if get_ext(name) in VALID_ARCHIVES:
res = sabnzbd.dirscanner.ProcessArchiveFile(\
fn, name, pp=pp, script=script, cat=cat, priority=priority, keep=True, nzbname=nzbname)
elif get_ext(name) in ('.nzb', '.gz'):
elif get_ext(name) in ('.nzb', '.gz', '.bz2'):
res = sabnzbd.dirscanner.ProcessSingleFile(\
fn, name, pp=pp, script=script, cat=cat, priority=priority, keep=True, nzbname=nzbname)
else:

13
sabnzbd/dirscanner.py

@ -25,6 +25,7 @@ import logging
import re
import zipfile
import gzip
import bz2
import threading
import sabnzbd
@ -145,7 +146,7 @@ def ProcessSingleFile(filename, path, pp=None, script=None, cat=None, catdir=Non
priority=None, nzbname=None, reuse=False, nzo_info=None, dup_check=True, url='',
password=None):
""" Analyse file and create a job from it
Supports NZB, NZB.GZ and GZ.NZB-in-disguise
Supports NZB, NZB.BZ2, NZB.GZ and GZ.NZB-in-disguise
returns (status, nzo_ids)
status: -2==Error/retry, -1==Error, 0==OK, 1==OK-but-ignorecannot-delete
"""
@ -164,6 +165,10 @@ def ProcessSingleFile(filename, path, pp=None, script=None, cat=None, catdir=Non
# gzip file or gzip in disguise
name = filename.replace('.nzb.gz', '.nzb')
f = gzip.GzipFile(path, 'rb')
elif (b1 == 'B' and b2 == 'Z'):
# bz2 file or bz2 in disguise
name = filename.replace('.nzb.bz2', '.nzb')
f = bz2.BZ2File(path, 'rb')
else:
name = filename
f = open(path, 'rb')
@ -316,7 +321,7 @@ class DirScanner(threading.Thread):
continue
ext = os.path.splitext(path)[1].lower()
candidate = ext in ('.nzb', '.gz') or ext in VALID_ARCHIVES
candidate = ext in ('.nzb', '.gz', '.bz2') or ext in VALID_ARCHIVES
if candidate:
try:
stat_tuple = os.stat(path)
@ -363,8 +368,8 @@ class DirScanner(threading.Thread):
else:
self.ignored[path] = 1
# Handle .nzb, .nzb.gz or gzip-disguised-as-nzb
elif ext == '.nzb' or filename.lower().endswith('.nzb.gz'):
# Handle .nzb, .nzb.gz or gzip-disguised-as-nzb or .bz2
elif ext == '.nzb' or filename.lower().endswith('.nzb.gz') or filename.lower().endswith('.nzb.bz2'):
res, nzo_id = ProcessSingleFile(filename, path, catdir=catdir, url=path)
if res < 0:
self.suspected[path] = stat_tuple

2
sabnzbd/osxmenu.py

@ -746,7 +746,7 @@ class SABnzbdDelegate(NSObject):
if get_ext(name) in VALID_ARCHIVES:
#logging.info('[osx] archive')
dirscanner.ProcessArchiveFile(fn, name, keep=True)
elif get_ext(name) in ('.nzb', '.gz'):
elif get_ext(name) in ('.nzb', '.gz', '.bz2'):
#logging.info('[osx] nzb')
dirscanner.ProcessSingleFile(fn, name, keep=True)
#logging.info('opening done')

3
sabnzbd/sabtraylinux.py

@ -139,9 +139,10 @@ class StatusIcon(Thread):
dialog.set_select_multiple(True)
filter = gtk.FileFilter()
filter.set_name("*.nbz,*.nbz.gz,*.zip,*.rar")
filter.set_name("*.nbz,*.nbz.gz,*.bz2,*.zip,*.rar")
filter.add_pattern("*.nzb*")
filter.add_pattern("*.nzb.gz")
filter.add_pattern("*.nzb.bz2")
filter.add_pattern("*.zip")
filter.add_pattern("*.rar")
dialog.add_filter(filter)

4
sabnzbd/skintext.py

@ -844,7 +844,7 @@ SKIN_TEXT = {
'Glitter-deleteJobAndFolders' : TT('Remove NZB & Delete Files'),
'Glitter-addFromURL' : TT('Fetch NZB from URL'),
'Glitter-addFromFile' : TT('Upload NZB'),
'Glitter-nzbFormats' : TT('Formats: .nzb, .rar, .zip, .gz'),
'Glitter-nzbFormats' : TT('Formats: .nzb, .rar, .zip, .gz, .bz2'),
'Glitter-unpackPassword' : TT('Password for unpacking'),
'Glitter-submit' : TT('Submit'),
'Glitter-removeSelected' : TT('Remove all selected files'),
@ -919,7 +919,7 @@ SKIN_TEXT = {
'Plush-blockRefresh' : TT('Block Refreshes on Hover'),
'Plush-fetch' : TT('Fetch'), #: Fetch from URL button in "Add NZB" dialog box
'Plush-upload' : TT('Upload'), #: Upload button in "Add NZB" dialog box
'Plush-uploadTip' : TT('Upload: .nzb .rar .zip .gz'),
'Plush-uploadTip' : TT('Upload: .nzb .rar .zip .gz, .bz2'),
'Plush-addnzb-filename' : TT('Optionally specify a filename'),
'Plush-progress' : TT('Progress'),
'Plush-remaining' : TT('Remaining'),

2
sabnzbd/urlgrabber.py

@ -200,7 +200,7 @@ class URLGrabber(Thread):
del data
# Check if nzb file
if os.path.splitext(filename)[1].lower() in ('.nzb', '.gz'):
if os.path.splitext(filename)[1].lower() in ('.nzb', '.gz', 'bz2'):
res, nzo_ids = dirscanner.ProcessSingleFile(filename, path, pp=pp, script=script, cat=cat, priority=priority, \
nzbname=nzbname, nzo_info=nzo_info, url=future_nzo.url, keep=False)
if res == 0:

2
sabnzbd/utils/upload.py

@ -58,7 +58,7 @@ def add_local(f):
if fn:
if get_ext(fn) in VALID_ARCHIVES:
ProcessArchiveFile(fn, f, keep=True)
elif get_ext(fn) in ('.nzb', '.gz'):
elif get_ext(fn) in ('.nzb', '.gz', '.bz2'):
ProcessSingleFile(fn, f, keep=True)
else:
logging.error("Filename not found: %s", f)

Loading…
Cancel
Save