added sabnzbd & nzbmatrix support

This commit is contained in:
Remy
2011-05-23 20:56:28 -07:00
parent e0c8deb38b
commit 77fdbe4cee
12 changed files with 115 additions and 110 deletions

View File

@@ -1,7 +1,8 @@
import os
from configobj import ConfigObj
from headphones import config_file
config = ConfigObj(os.path.join(os.path.dirname(__file__), 'config.ini'))
config = ConfigObj(config_file)
General = config['General']
http_host = General['http_host']
@@ -11,9 +12,11 @@ http_password = General['http_password']
launch_browser = General['launch_browser']
usenet_retention = General['usenet_retention']
include_lossless = General['include_lossless']
flac_to_mp3 = General['flac_to_mp3']
move_to_itunes = General['move_to_itunes']
path_to_itunes = General['path_to_itunes']
rename_mp3s = General['rename_mp3s']
cleanup = General['cleanup']
add_album_art = General['add_album_art']
music_download_dir = General['music_download_dir']
NZBMatrix = config['NZBMatrix']
@@ -74,18 +77,20 @@ form = '''<div class="table"><div class="config">
<input type="text" name="nzbmatrix_apikey" value="%s" size="46" maxlength="40"/></td></tr></table>
<h1><u>Quality & Post Processing</u></h1>
<table class="configtable"><tr><td><p>Album Quality:</p>
<input type="checkbox" name="include_lossless" value="1" %s/>Include lossless</td>
<input type="checkbox" name="include_lossless" value="1" %s/>Include lossless
<input type="checkbox" name="flac_to_mp3" value="1" %s/>Convert lossless to mp3</td>
<td><p>iTunes:</p>
<input type="checkbox" name="move_to_itunes" value="1" %s/>Move downloads to iTunes</td></tr>
<tr><td><br /><p>Path to iTunes folder:</p>
<input type="text" name="path_to_itunes" value="%s" size="60" maxlength="40"/><br />
<p class="smalltext">i.e. Music/iTunes or /Users/name/Music/iTunes</p></td>
<td><p>Renaming & Metadata:</p>
<input type="checkbox" name="rename_mp3s" value="1" %s/>Rename & add metadata</td></tr>
<input type="checkbox" name="rename_mp3s" value="1" %s/>Rename & add metadata<br /><br />
<input type="checkbox" name="cleanup" value="1" %s/>Delete leftover files</td></td></tr>
<tr><td><br /><p>Album Art:</p>
<input type="checkbox" name="add_album_art" value="1" %s/>Add album art</td></tr></table>
<p class="center"><input type="submit" value=" Save Changes "/></p></form></div></div>''' % (http_host, http_username,
http_port, http_password, var_to_chk(launch_browser), sab_host, sab_username, sab_apikey, sab_password,
sab_category, music_download_dir, usenet_retention, var_to_chk(nzbmatrix), nzbmatrix_username, nzbmatrix_apikey,
var_to_chk(include_lossless), var_to_chk(move_to_itunes), path_to_itunes, var_to_chk(rename_mp3s),
var_to_chk(add_album_art))
var_to_chk(include_lossless), var_to_chk(flac_to_mp3), var_to_chk(move_to_itunes), path_to_itunes, var_to_chk(rename_mp3s),
var_to_chk(cleanup), var_to_chk(add_album_art))

View File

@@ -67,7 +67,7 @@ h1{
}
.nav{
padding: 2px;
font-size:20px;
font-size:19px;
color: grey;
background-color: #bbbbbb;
width: 95%;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 417 B

View File

@@ -1,30 +0,0 @@
import sys
from musicbrainz2.webservice import Query, ArtistFilter, WebServiceError
def findArtist(self, name):
if len(name) < 2:
return '''Please enter an artist'''
q = Query()
try:
f = ArtistFilter(name, limit=5)
artistResults = q.getArtists(f)
except WebServiceError, e:
print 'Error:', e
sys.exit(1)
for result in artistResults:
artist = result.artist
return '''
Score = %s
Id = %s
Name = %s
Sort Name = %s
''' % result.score, artist.id, artist.name, artist.sortName

View File

@@ -1,13 +1,84 @@
#!/usr/bin/env python
import os
import cherrypy
from webServer import Headphones
from cherrypy.process.plugins import Daemonizer
from optparse import OptionParser
from configobj import ConfigObj
from configcreate import configCreate
import webServer
import time
from threadtools import threadtool
import os
#set up paths
FULL_PATH = os.path.dirname(os.path.abspath(__file__))
config_file = os.path.join(FULL_PATH, 'config.ini')
db = os.path.join(FULL_PATH, 'headphones.db')
if os.path.exists(config_file):
pass
else:
configCreate(config_file)
settings = ConfigObj(config_file)['General']
def serverstart():
parser = OptionParser()
parser.add_option("-d", "--daemonize", action="store_true", dest="daemonize")
parser.add_option("-q", "--quiet", action="store_true", dest="quiet")
(options, args) = parser.parse_args()
if options.quiet or options.daemonize:
cherrypy.config.update({'log.screen': False})
cherrypy.config.update({
'server.thread_pool': 10,
'server.socket_port': int(settings['http_port']),
'server.socket_host': settings['http_host']
})
conf = {
'/': {
'tools.staticdir.root': FULL_PATH
},
'/data/images':{
'tools.staticdir.on': True,
'tools.staticdir.dir': "data/images"
},
'/data/css':{
'tools.staticdir.on': True,
'tools.staticdir.dir': "data/css"
},
'/data/js':{
'tools.staticdir.on': True,
'tools.staticdir.dir': "data/js"
}
}
if settings['http_password'] != "":
conf['/'].update({
'tools.auth_basic.on': True,
'tools.auth_basic.realm': 'mordor',
'tools.auth_basic.checkpassword': cherrypy.lib.auth_basic.checkpassword_dict(
{settings['http_username']:settings['http_password']})
})
if options.daemonize:
Daemonizer(cherrypy.engine).subscribe()
#Start threads
threadtool(cherrypy.engine).subscribe()
cherrypy.quickstart(webServer.Headphones(), config = conf)
#path to config_file
config_file = os.path.join(os.path.dirname(__file__), 'server.conf')
if __name__ == '__main__':
cherrypy.quickstart(Headphones(), config=config_file)
serverstart()

View File

@@ -1,29 +0,0 @@
import sys
import musicbrainz2.webservice as ws
import musicbrainz2.model as m
def findArtist(name):
if len(name) == 0 or name == 'Add an artist':
return '''<p align="right"><font color="red">Please enter an artist</font></p>'''
q = ws.Query()
f = ws.ArtistFilter(name, limit=5)
artistResults = ws.Query().getArtists(ws.ArtistFilter(name, limit=5))
if len(artistResults) > 1:
return '''We found a few different artists. Which one did you want?<br /><br />'''
for result in artistResults:
artist = result.artist
return '''<a href="/addArtist?artistid=%s"> %s </a><br />''' % (artist.id, artist.name)
elif len(artistRestuls) == 1:
return '''Ok, we're going to add %s''' % artist.name
else:
return '''We couldn't find any artists!'''

View File

@@ -1,19 +0,0 @@
[global]
server.socket_host = "0.0.0.0"
server.socket_port = 8181
server.thread_pool = 10
[/]
tools.staticdir.root = os.getcwd()
[/data/images]
tools.staticdir.on = True
tools.staticdir.dir = "data/images"
[/data/css]
tools.staticdir.on = True
tools.staticdir.dir = "data/css"
[/data/js]
tools.staticdir.on = True
tools.staticdir.dir = "data/js"

View File

@@ -1,8 +1,10 @@
_header = '''
<html>
<head>
<title>headphones</title>
<title>Headphones</title>
<link rel="stylesheet" type="text/css" href="data/css/style.css" />
<link rel="icon" type="image/png" href="data/images/headphoneslogo.png" />
<link rel="apple-touch-icon" href="data/images/headphoneslogo.png" />
</head>
<body>
<div class="container">'''

View File

@@ -1,7 +1,6 @@
import templates
import config
import cherrypy
import search
import musicbrainz2.webservice as ws
import musicbrainz2.model as m
import musicbrainz2.utils as u
@@ -11,10 +10,9 @@ import time
import sqlite3
import sys
import configobj
from headphones import FULL_PATH, config_file
database = os.path.join(os.path.dirname(__file__), 'headphones.db')
database = os.path.join(FULL_PATH, 'headphones.db')
class Headphones:
@@ -32,7 +30,7 @@ class Headphones:
i = 0
page.append('''<div class="table"><table border="0" cellpadding="3">
<tr>
<th align="left" width="150">Artist Name</th>
<th align="left" width="170">Artist Name</th>
<th align="center" width="100">Status</th>
<th align="center" width="300">Upcoming Albums</th>
<th> </th>
@@ -41,7 +39,7 @@ class Headphones:
c.execute('''SELECT AlbumTitle, ReleaseDate, DateAdded, AlbumID from albums WHERE ArtistName="%s" order by ReleaseDate DESC''' % results[i][0])
latestalbum = c.fetchall()
if latestalbum[0][1] > latestalbum[0][2]:
newalbumName = '<font color="#5DFC0A" size="3px"><a href="albumPage?name=%s">%s' % (latestalbum[0][3], latestalbum[0][0])
newalbumName = '<font color="#5DFC0A" size="3px"><a href="albumPage?name=%s"><i>%s</i>' % (latestalbum[0][3], latestalbum[0][0])
releaseDate = '(%s)</a></font>' % latestalbum[0][1]
else:
newalbumName = '<font color="#CFCFCF">None</font>'
@@ -50,10 +48,10 @@ class Headphones:
newStatus = '''<font color="red"><b>%s</b></font>(<A class="external" href="resumeArtist?ArtistID=%s">resume</a>)''' % (results[i][2], results[i][1])
else:
newStatus = '''%s(<A class="external" href="pauseArtist?ArtistID=%s">pause</a>)''' % (results[i][2], results[i][1])
page.append('''<tr><td align="left" width="280"><a href="artistPage?ArtistID=%s">%s</a>
page.append('''<tr><td align="left" width="300"><a href="artistPage?ArtistID=%s">%s</a>
(<A class="external" href="http://musicbrainz.org/artist/%s">link</a>) [<A class="externalred" href="deleteArtist?ArtistID=%s">delete</a>]</td>
<td align="center" width="160">%s</td>
<td align="center"><b><i>%s %s</i></b> </td></tr>''' % (results[i][1], results[i][0], results[i][1], results[i][1], newStatus, newalbumName, releaseDate))
<td align="center">%s %s</td></tr>''' % (results[i][1], results[i][0], results[i][1], results[i][1], newStatus, newalbumName, releaseDate))
i = i+1
page.append('''</table></div>''')
else:
@@ -89,6 +87,8 @@ class Headphones:
newStatus = '''<b>%s</b>[<A class="external" href="unqueueAlbum?AlbumID=%s&ArtistID=%s">skip</a>]''' % (results[i][3], results[i][2], ArtistID)
elif results[i][3] == 'Downloaded':
newStatus = '''<b>%s</b>[<A class="external" href="queueAlbum?AlbumID=%s&ArtistID=%s">retry</a>]''' % (results[i][3], results[i][2], ArtistID)
elif results[i][3] == 'Snatched':
newStatus = '''<b>%s</b>[<A class="external" href="queueAlbum?AlbumID=%s&ArtistID=%s">retry</a>]''' % (results[i][3], results[i][2], ArtistID)
else:
newStatus = '%s' % (results[i][3])
page.append('''<tr><td align="left"><img src="http://ec1.images-amazon.com/images/P/%s.01.MZZZZZZZ.jpg" height="50" width="50"></td>
@@ -257,7 +257,10 @@ class Headphones:
c.execute('UPDATE albums SET status = "Wanted" WHERE AlbumID="%s"' % AlbumID)
conn.commit()
c.close()
import searcher
searcher.searchNZB(AlbumID)
raise cherrypy.HTTPRedirect("/artistPage?ArtistID=%s" % ArtistID)
queueAlbum.exposed = True
@@ -271,9 +274,6 @@ class Headphones:
unqueueAlbum.exposed = True
def upcoming(self):
page = [templates._header]
page.append(templates._logobar)
@@ -308,15 +308,16 @@ class Headphones:
config.exposed = True
def configUpdate(self, http_host='localhost', http_username=None, http_port=8181, http_password=None, launch_browser=0,
def configUpdate(self, http_host='127.0.0.1', http_username=None, http_port=8181, http_password=None, launch_browser=0,
sab_host=None, sab_username=None, sab_apikey=None, sab_password=None, sab_category=None, music_download_dir=None,
usenet_retention=None, nzbmatrix=0, nzbmatrix_username=None, nzbmatrix_apikey=None, include_lossless=0,
move_to_itunes=0, path_to_itunes=None, rename_mp3s=0, add_album_art=0):
flac_to_mp3=0, move_to_itunes=0, path_to_itunes=None, rename_mp3s=0, cleanup=0, add_album_art=0):
configs = configobj.ConfigObj(os.path.join(os.path.dirname(__file__), 'config.ini'))
configs = configobj.ConfigObj(config_file)
SABnzbd = configs['SABnzbd']
General = configs['General']
NZBMatrix = configs['NZBMatrix']
NZBMatrix = configs['NZBMatrix']
General['http_host'] = http_host
General['http_port'] = http_port
General['http_username'] = http_username
@@ -333,12 +334,15 @@ class Headphones:
NZBMatrix['nzbmatrix_username'] = nzbmatrix_username
NZBMatrix['nzbmatrix_apikey'] = nzbmatrix_apikey
General['include_lossless'] = include_lossless
General['flac_to_mp3'] = flac_to_mp3
General['move_to_itunes'] = move_to_itunes
General['path_to_itunes'] = path_to_itunes
General['rename_mp3s'] = rename_mp3s
General['cleanup'] = cleanup
General['add_album_art'] = add_album_art
configs.write()
reload(config)
raise cherrypy.HTTPRedirect("/config")
@@ -346,5 +350,6 @@ class Headphones:
configUpdate.exposed = True
def shutdown(self):
sys.exit('Headphones is shutting down')
shutdown.exposed = True
sys.exit()
shutdown.exposed = True