mirror of
https://github.com/rembo10/headphones.git
synced 2026-07-22 00:44:00 +01:00
modified: data/interfaces/default/config.html
modified: headphones/__init__.py modified: headphones/postprocessor.py new file: headphones/prowl.py modified: headphones/sab.py modified: headphones/webserve.py new file: lib/httplib2/__init__.py new file: lib/httplib2/iri2uri.py
This commit is contained in:
+18
-2
@@ -130,6 +130,10 @@ ENCODEROUTPUTFORMAT = None
|
||||
ENCODERQUALITY = None
|
||||
ENCODERVBRCBR = None
|
||||
ENCODERLOSSLESS = False
|
||||
PROWL_ENABLED = True
|
||||
PROWL_PRIORITY = 1
|
||||
PROWL_KEYS = None
|
||||
PROWL_ONSNATCH = True
|
||||
|
||||
def CheckSection(sec):
|
||||
""" Check if INI section exists, if not create it """
|
||||
@@ -191,7 +195,7 @@ def initialize():
|
||||
NZBMATRIX, NZBMATRIX_USERNAME, NZBMATRIX_APIKEY, NEWZNAB, NEWZNAB_HOST, NEWZNAB_APIKEY, \
|
||||
NZBSORG, NZBSORG_UID, NZBSORG_HASH, NEWZBIN, NEWZBIN_UID, NEWZBIN_PASSWORD, LASTFM_USERNAME, INTERFACE, FOLDER_PERMISSIONS, \
|
||||
ENCODERFOLDER, ENCODER, BITRATE, SAMPLINGFREQUENCY, ENCODE, ADVANCEDENCODER, ENCODEROUTPUTFORMAT, ENCODERQUALITY, ENCODERVBRCBR, \
|
||||
ENCODERLOSSLESS
|
||||
ENCODERLOSSLESS, PROWL_ENABLED, PROWL_PRIORITY, PROWL_KEYS, PROWL_ONSNATCH
|
||||
|
||||
if __INITIALIZED__:
|
||||
return False
|
||||
@@ -203,6 +207,7 @@ def initialize():
|
||||
CheckSection('Newznab')
|
||||
CheckSection('NZBsorg')
|
||||
CheckSection('Newzbin')
|
||||
CheckSection('Prowl')
|
||||
|
||||
# Set global variables based on config file or use defaults
|
||||
try:
|
||||
@@ -290,6 +295,11 @@ def initialize():
|
||||
ENCODERQUALITY = check_setting_int(CFG, 'General', 'encoderquality', 2)
|
||||
ENCODERVBRCBR = check_setting_str(CFG, 'General', 'encodervbrcbr', 'cbr')
|
||||
ENCODERLOSSLESS = bool(check_setting_int(CFG, 'General', 'encoderlossless', 1))
|
||||
|
||||
PROWL_ENABLED = bool(check_setting_int(CFG, 'Prowl', 'prowl_enabled', 0))
|
||||
PROWL_KEYS = check_setting_str(CFG, 'Prowl', 'prowl_keys', '')
|
||||
PROWL_ONSNATCH = bool(check_setting_int(CFG, 'Prowl', 'prowl_onsnatch', 0))
|
||||
PROWL_PRIORITY = check_setting_int(CFG, 'Prowl', 'prowl_priority', 0)
|
||||
|
||||
if not LOG_DIR:
|
||||
LOG_DIR = os.path.join(DATA_DIR, 'logs')
|
||||
@@ -471,6 +481,12 @@ def config_write():
|
||||
new_config['Newzbin']['newzbin_uid'] = NEWZBIN_UID
|
||||
new_config['Newzbin']['newzbin_password'] = NEWZBIN_PASSWORD
|
||||
|
||||
new_config['Prowl'] = {}
|
||||
new_config['Prowl']['prowl_enabled'] = PROWL_ENABLED
|
||||
new_config['Prowl']['prowl_keys'] = PROWL_KEYS
|
||||
new_config['Prowl']['prowl_onsnatch'] = PROWL_ONSNATCH
|
||||
new_config['Prowl']['prowl_priority'] = PROWL_PRIORITY
|
||||
|
||||
new_config['General']['lastfm_username'] = LASTFM_USERNAME
|
||||
new_config['General']['interface'] = INTERFACE
|
||||
new_config['General']['folder_permissions'] = FOLDER_PERMISSIONS
|
||||
@@ -625,4 +641,4 @@ def shutdown(restart=False, update=False):
|
||||
logger.info('Restarting Headphones with ' + str(popen_list))
|
||||
subprocess.Popen(popen_list, cwd=os.getcwd())
|
||||
|
||||
os._exit(0)
|
||||
os._exit(0)
|
||||
|
||||
@@ -2,6 +2,8 @@ import os
|
||||
import time
|
||||
import encode
|
||||
import urllib, shutil, re
|
||||
from headphones import prowl
|
||||
from headphones.prowl import PROWL
|
||||
import lib.beets as beets
|
||||
from lib.beets import autotag
|
||||
from lib.beets.mediafile import MediaFile
|
||||
@@ -251,6 +253,13 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list)
|
||||
updateHave(albumpath)
|
||||
|
||||
logger.info('Post-processing for %s - %s complete' % (release['ArtistName'], release['AlbumTitle']))
|
||||
if headphones.PROWL_ONSNATCH:
|
||||
pushmessage = release['ArtistName'] + ' - ' + release['AlbumTitle']
|
||||
logger.info(u"Prowl request")
|
||||
prowl = PROWL()
|
||||
prowl.notify(pushmessage,"Download and Postprocessing completed")
|
||||
|
||||
|
||||
|
||||
def embedAlbumArt(artwork, downloaded_track_list):
|
||||
logger.info('Embedding album art')
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
from headphones import logger
|
||||
import base64
|
||||
import cherrypy
|
||||
import urllib
|
||||
import urllib2
|
||||
import headphones
|
||||
from httplib import HTTPSConnection
|
||||
from urllib import urlencode
|
||||
|
||||
class PROWL:
|
||||
|
||||
keys = []
|
||||
priority = []
|
||||
|
||||
def __init__(self):
|
||||
self.enabled = headphones.PROWL_ENABLED
|
||||
self.keys = headphones.PROWL_KEYS
|
||||
self.priority = headphones.PROWL_PRIORITY
|
||||
pass
|
||||
|
||||
def conf(self, options):
|
||||
return cherrypy.config['config'].get('Prowl', options)
|
||||
|
||||
def notify(self, message, event):
|
||||
if not headphones.PROWL_ENABLED:
|
||||
return
|
||||
|
||||
http_handler = HTTPSConnection("api.prowlapp.com")
|
||||
|
||||
data = {'apikey': headphones.PROWL_KEYS,
|
||||
'application': 'Headphones',
|
||||
'event': event,
|
||||
'description': message.encode("utf-8"),
|
||||
'priority': headphones.PROWL_PRIORITY }
|
||||
|
||||
http_handler.request("POST",
|
||||
"/publicapi/add",
|
||||
headers = {'Content-type': "application/x-www-form-urlencoded"},
|
||||
body = urlencode(data))
|
||||
response = http_handler.getresponse()
|
||||
request_status = response.status
|
||||
|
||||
if request_status == 200:
|
||||
logger.info(u"Prowl notifications sent.")
|
||||
return True
|
||||
elif request_status == 401:
|
||||
logger.info(u"Prowl auth failed: %s" % response.reason)
|
||||
return False
|
||||
else:
|
||||
logger.info(u"Prowl notification failed.")
|
||||
return False
|
||||
|
||||
def updateLibrary(self):
|
||||
#For uniformity reasons not removed
|
||||
return
|
||||
|
||||
def test(self, keys, priority):
|
||||
|
||||
self.enabled = True
|
||||
self.keys = keys
|
||||
self.priority = priority
|
||||
|
||||
self.notify('ZOMG Lazors Pewpewpew!', 'Test Message')
|
||||
+7
-1
@@ -25,7 +25,8 @@ import urllib2, cookielib
|
||||
|
||||
from headphones.common import USER_AGENT
|
||||
from headphones import logger
|
||||
|
||||
from headphones import prowl
|
||||
from headphones.prowl import PROWL
|
||||
|
||||
def sendNZB(nzb):
|
||||
|
||||
@@ -116,6 +117,11 @@ def sendNZB(nzb):
|
||||
|
||||
if sabText == "ok":
|
||||
logger.info(u"NZB sent to SAB successfully")
|
||||
if headphones.PROWL_ONSNATCH:
|
||||
logger.info(u"Prowl request")
|
||||
prowl = PROWL()
|
||||
prowl.notify(nzb.name,"Download started")
|
||||
|
||||
return True
|
||||
elif sabText == "Missing authentication":
|
||||
logger.info(u"Incorrect username/password sent to SAB, NZB not sent")
|
||||
|
||||
+11
-2
@@ -378,7 +378,11 @@ class WebInterface(object):
|
||||
"samplingfrequency": headphones.SAMPLINGFREQUENCY,
|
||||
"encodervbrcbr": headphones.ENCODERVBRCBR,
|
||||
"encoderquality": headphones.ENCODERQUALITY,
|
||||
"encoderlossless": checked(headphones.ENCODERLOSSLESS)
|
||||
"encoderlossless": checked(headphones.ENCODERLOSSLESS),
|
||||
"prowl_enabled": checked(headphones.PROWL_ENABLED),
|
||||
"prowl_onsnatch": checked(headphones.PROWL_ONSNATCH),
|
||||
"prowl_keys": headphones.PROWL_KEYS,
|
||||
"prowl_priority": headphones.PROWL_PRIORITY
|
||||
}
|
||||
return serve_template(templatename="config.html", title="Settings", config=config)
|
||||
config.exposed = True
|
||||
@@ -390,7 +394,8 @@ class WebInterface(object):
|
||||
nzbsorg=0, nzbsorg_uid=None, nzbsorg_hash=None, newzbin=0, newzbin_uid=None, newzbin_password=None, preferred_quality=0, preferred_bitrate=None, detect_bitrate=0, move_files=0,
|
||||
torrentblackhole_dir=None, download_torrent_dir=None, numberofseeders=10, use_isohunt=0, use_kat=0, use_mininova=0,
|
||||
rename_files=0, correct_metadata=0, cleanup_files=0, add_album_art=0, embed_album_art=0, embed_lyrics=0, destination_dir=None, folder_format=None, file_format=None, include_extras=0, interface=None, log_dir=None,
|
||||
encode=0, encoder=None, bitrate=None, samplingfrequency=None, encoderfolder=None, advancedencoder=None, encoderoutputformat=None, encodervbrcbr=None, encoderquality=None, encoderlossless=0):
|
||||
encode=0, encoder=None, bitrate=None, samplingfrequency=None, encoderfolder=None, advancedencoder=None, encoderoutputformat=None, encodervbrcbr=None, encoderquality=None, encoderlossless=0,
|
||||
prowl_enabled=0, prowl_onsnatch=0, prowl_keys=None, prowl_priority=0):
|
||||
|
||||
headphones.HTTP_HOST = http_host
|
||||
headphones.HTTP_PORT = http_port
|
||||
@@ -450,6 +455,10 @@ class WebInterface(object):
|
||||
headphones.ENCODERVBRCBR = encodervbrcbr
|
||||
headphones.ENCODERQUALITY = int(encoderquality)
|
||||
headphones.ENCODERLOSSLESS = encoderlossless
|
||||
headphones.PROWL_ENABLED = prowl_enabled
|
||||
headphones.PROWL_ONSNATCH = prowl_onsnatch
|
||||
headphones.PROWL_KEYS = prowl_keys
|
||||
headphones.PROWL_PRIORITY = prowl_priority
|
||||
|
||||
headphones.config_write()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user