Merge pull request #29 from Chaosbit/cheetah

Cheetah
This commit is contained in:
rembo10
2011-07-10 19:42:30 -07:00
13 changed files with 544 additions and 138 deletions

View File

@@ -0,0 +1,6 @@
</div>
<div class="footer">
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,30 @@
#attr title = ""
#attr rootPath = ""
#attr scripts = ""
#attr styles = ""
<html>
<head>
<title>Headphones $title</title>
<link rel="stylesheet" type="text/css" href="$rootPath/data/css/style.css" />
<link rel="icon" type="image/x-icon" href="$rootPath/data/images/favicon.ico" />
<link rel="apple-touch-icon" href="$rootPath/data/images/headphoneslogo.png" />
</head>
<body>
<div class="container">
<div class="logo"><a href="/">
<img src="$rootPath/data/images/headphoneslogo.png" border="0">headphones<a></div>
<div class="search"><form action="findArtist" method="GET">
<input type="text" value="Add an artist" onfocus="if
(this.value==this.defaultValue) this.value='';" name="name" />
<input type="submit" /></form></div>
</div>
<br />
<div class="nav">
<a href="/">HOME</a>
<a href="/upcoming">UPCOMING</a>
<a href="/manage">MANAGE</a>
<a href="/history">HISTORY</a>
<a href="/config">SETTINGS</a>
<a href="/shutdown"><font color="red">SHUTDOWN</font></a>
</div>
<div class="table">

View File

@@ -0,0 +1,45 @@
#attr $albumASIN = ""
#attr $albumTitle = ""
#attr $albumID = ""
#attr $artitstID = ""
#attr $artistName = ""
#import os.path
#import time
#include os.path.abspath($appPath+"/data/interfaces/default/_inc_header.tmpl")
<table border="0" cellpadding="3">
<tr>
<td colspan="4" align="center">
#if $albumASIN:
<img src="http://ec1.images-amazon.com/images/P/${albumASIN}.01.LZZZZZZZ.jpg" height="200" width="200">
<br />
#end if
<br />
<a href="artistPage?ArtistID=$artistID">${artistName}</a> -${albumTitle}<br />
<a href="queueAlbum?AlbumID=${albumID}&ArtistID=${artistID}">Download <br />
</td>
</tr>
<tr>
<th align="left" width="100">Track #</th>
<th align="left" width="100">Track Title</th>
<th align="center" width="300">Duration</th>
<th></th>
</tr>
#for $track in $tracks
<tr>
<td align="left" width="120">${track[7]}</td>
<td align="left" width="240">
${track[3]}(<a class="external" href="http://musicbrainz.org/recording/${track[5]}.html">link</a>)
</td>
<td align="center">
#try
#echo time.strftime("%M:%S", time.gmtime(int($track[4])/1000))
#except
n/a
#end try
</td>
</tr>
#end for
</table>
#include os.path.abspath($appPath+"/data/interfaces/default/_inc_footer.tmpl")

View File

@@ -0,0 +1,13 @@
#attr $artistName = ""
#attr $artistUuid = ""
#attr $releaseGroups = []
#import os.path
#include os.path.abspath($appPath+"/data/interfaces/default/_inc_header.tmpl")
Artist Name: $artistName <br />
Unique ID: $artistUuid <br />
<br />
Albums:<br />
#for $releaseGroup in $releaseGroups:
$releaseGroup <br />
#end for
#include os.path.abspath($appPath+"/data/interfaces/default/_inc_footer.tmpl")

View File

@@ -0,0 +1,39 @@
#attr $artistName = ""
#attr $artistID = ""
#import os.path
#include os.path.abspath($appPath+"/data/interfaces/default/_inc_header.tmpl")
<table border="0" cellpadding="3">
<tr>
<th colspan="4">
<p align="center">$artistName <br /></p>
</th>
</tr>
<tr>
<td align="left" width="50"></td>
<td align="left" width="120">Album Name</td>
<td align="center" width="100">Release Date</td>
<td align="center" width="300">Status</td>
</tr>
#for $album in $albums
<tr>
<td align="left">
<img src="http://ec1.images-amazon.com/images/P/$album[5].01.MZZZZZZZ.jpg" height="50" widtd="50">
</td>
<td align="left" width="240"><a href="albumPage?AlbumID=$album[2]">$album[0]</a>
(<A class="external" href="http://musicbrainz.org/release/${album[2]}.html">link</a>)</td>
<td align="center" widtd="160">$album[1]</td>
<td align="center">
#if $album[3] == 'Skipped':
<b>$album[3]</b>[<A class="external" href="queueAlbum?AlbumID=${album[2]}&ArtistID=$artistID">want</a>]
#elif $album[3] == 'Wanted':
<b>$album[3]</b>[<a class="external" href="unqueueAlbum?AlbumID=$album[2]&ArtistID=$artistID">skip</a>]
#elif $album[3] == 'Downloaded' or $album[3] == 'Snatched':
<b>$album[3]</b>[<a class="external" href="queueAlbum?AlbumID=$album[2]&ArtistID=$artistID">retry</a>]
#else:
$album[3]
#end if
</td>
</tr>
#end for
</table>
#include os.path.abspath($appPath+"/data/interfaces/default/_inc_footer.tmpl")

View File

@@ -0,0 +1,238 @@
#import os.path
#import config
#include os.path.abspath($appPath+"/data/interfaces/default/_inc_header.tmpl")
<center>
<div class="smalltext">
<a href="#web_interface" >Web Interface</a> |
<a href="#download" class="smalltext">Download Settings</a> |
<a href="#providers" class="smalltext">Search Providers</a> |
<a href="#post_processing" class="smalltext">Quality &amp; Post Processing</a>
</div>
</center>
<div class="config">
<form action="configUpdate" method="post">
<a name="web_interface"><h1><u>Web Interface</u></h1></a>
<table class="configtable" summary="Web Interface">
<tr>
<td>
<p>
HTTP Host: <br><br>
<input type="text" name="http_host" value="${config.General['http_host']}" size="30" maxlength="40"><br>
<i class="smalltext">i.e. localhost or 0.0.0.0</i>
</p>
</td>
<td>
<p>
HTTP Username: <br><br>
<input type="text" name="http_username" value="${config.General['http_username']}" size="30" maxlength="40">
</p>
</td>
</tr>
<tr>
<td>
<p>
HTTP Port: <br><br>
<input type="text" name="http_port" value="${config.General['http_port']}" size="20" maxlength="40">
</p>
</td>
<td>
<p>
HTTP Password: <br><br>
<input type="password" name="http_password" value="${config.General['http_password']}" size="30" maxlength="40">
</p>
</td>
</tr>
<tr>
<td>
<p>Launch Browser on Startup:<input type="checkbox" name="launch_browser" value="1" #if (config.General['launch_browser'] == '1') then "CHECKED" else ""#/></p>
</td>
</tr>
</table>
<a name="download"><h1><u>Download Settings</u></h1></a>
<table class="configtable" summary="Download Settings">
<tr>
<td>
<p>SABnzbd Host:</p><input type="text" name="sab_host" value="${config.SABnzbd['sab_host']}" size="30" maxlength="40"><br>
<i class="smalltext">usually localhost:8080</i>
</td>
<td>
<p>SABnzbd Username:</p><input type="text" name="sab_username" value="${config.SABnzbd['sab_username']}" size="20" maxlength="40">
</td>
</tr>
<tr>
<td>
<br>
<p>SABnzbd API:</p><input type="text" name="sab_apikey" value="${config.SABnzbd['sab_apikey']}" size="46" maxlength="40">
</td>
<td>
<br>
<p>SABnzbd Password:</p><input type="password" name="sab_password" value="${config.SABnzbd['sab_password']}" size="20" maxlength="40">
</td>
</tr>
<tr>
<td>
<br>
<p>SABnzbd Category:</p><input type="text" name="sab_category" value="${config.SABnzbd['sab_category']}" size="20" maxlength="40">
</td>
<td>
<br>
<p>Music Download Directory:</p><input type="text" name="music_download_dir" value="${config.General['music_download_dir']}" size="60" maxlength="40"><br>
<i class="smalltext">Absolute or relative path to the dir where SAB downloads your music<br>
i.e. Downloads/music or /Users/name/Downloads/music</i>
</td>
</tr>
<tr>
<td>
<br>
<p>Usenet Retention:</p><input type="text" name="usenet_retention" value="${config.General['usenet_retention']}" size="20" maxlength="40">
</td>
</tr>
</table>
<a name="providers"><h1><u>Search Providers</u></h1></a>
<table class="configtable" summary="Search Providers">
<tr>
<td>
<p>NZBMatrix: <input type="checkbox" name="nzbmatrix" value="1" #if (config.NZBMatrix['nzbmatrix'] == '1') then "checked" else ""#/></p>
</td>
<td>
<p>
NZBMatrix Username: <br>
<input type="text" name="nzbmatrix_username" value="${config.NZBMatrix['nzbmatrix_username']}" size="30" maxlength="40">
</p>
</td>
<td>
<p>
NZBMatrix API: <br>
<input type="text" name="nzbmatrix_apikey" value="${config.NZBMatrix['nzbmatrix_apikey']}" size="46" maxlength="40">
</p>
</td>
</tr>
<tr>
<td>
<br>
<p>Newznab: <input type="checkbox" name="newznab" value="1" #if (config.Newznab['newznab'] == '1') then "checked" else ""# /></p>
</td>
<td>
<br>
<p>
Newznab Host:<br>
<input type="text" name="newznab_host" value="${config.Newznab['newznab_host']}" size="30" maxlength="40"><br>
<i class="smalltext">i.e. http://nzb.su</i>
</p>
</td>
<td>
<br>
<p>
Newznab API:<br>
<input type="text" name="newznab_apikey" value="${config.Newznab['newznab_apikey']}" size="46" maxlength="40">
</p>
</td>
</tr>
<tr>
<td>
<br>
<p>NZBs.org:<input type="checkbox" name="nzbsorg" value="1" #if (config.NZBsorg['nzbsorg'] == '1') then "CHECKED" else ""# /></p>
</td>
<td>
<br>
<p>
NZBs.org UID:<br>
<input type="text" name="nzbsorg_uid" value="${config.NZBsorg['nzbsorg_uid']}" size="30" maxlength="40">
</p>
</td>
<td>
<br>
<p>
NZBs.org Hash:<br>
<input type="text" name="nzbsorg_hash" value="${config.NZBsorg['nzbsorg_hash']}" size="46" maxlength="40">
</p>
</td>
</tr>
</table>
<a name="post_processing"><h1><u>Quality &amp; Post Processing</u></h1></a>
<table class="configtable" summary="Quality & Post Processing">
<tr>
<td>
<p><b>Album Quality:</b></p>
<input type="checkbox" name="include_lossless" value="1" #if (config.General['include_lossless'] == '1') then "CHECKED" else ""# />Include lossless <br>
<input type="checkbox" name="flac_to_mp3" value="1" #if (config.General['flac_to_mp3'] == '1') then "CHECKED" else ""# />Convert lossless to mp3
</td>
<td>
<p>
<p><b>iTunes:</b></p>
<input type="checkbox" name="move_to_itunes" value="1" #if (config.General['move_to_itunes'] == '1') then "CHECKED" else ""# />Move downloads to iTunes
</p>
</td>
</tr>
<tr>
<td>
<br>
<p><b>Path to iTunes folder</b>:<br><input type="text" name="path_to_itunes" value="${config.General['path_to_itunes']}" size="60" maxlength="40">
<br>
<i class="smalltext">i.e. Music/iTunes or /Users/name/Music/iTunes</i>
</p>
</td>
<td>
<b>Renaming &amp; Metadata:</b>
<p>
<input type="checkbox" name="rename_mp3s" value="1" #if (config.General['rename_mp3s'] == '1') then "CHECKED" else ""# />Rename &amp; add metadata
<br>
<input type="checkbox" name="cleanup" value="1" #if (config.General['cleanup'] == '1') then "CHECKED" else ""# />Delete leftover files
</p>
</td>
</tr>
<tr>
<td>
<br>
<p><b>Album Art:</b></p>
<input type="checkbox" name="add_album_art" value="1" #if (config.General['add_album_art'] == '1') then "CHECKED" else ""#>Add album art
</td>
</tr>
</table>
<p class="center"><input type="submit" value="Save Changes"><br>
(For now, all changes require a restart to take effect)</p>
</form>
</div>
#include os.path.abspath($appPath+"/data/interfaces/default/_inc_footer.tmpl")

View File

@@ -0,0 +1,3 @@
#import os.path
#include os.path.abspath($appPath+"/data/interfaces/default/_inc_header.tmpl")
#include os.path.abspath($appPath+"/data/interfaces/default/_inc_footer.tmpl")

View File

@@ -0,0 +1,33 @@
#import os.path
#include os.path.abspath($appPath+"/data/interfaces/default/_inc_header.tmpl")
<table border="0" cellpadding="3">
<tr>
<th align="left" width="170">Artist Name</th>
<th align="center" width="100">Status</th>
<th align="center" width="300">Upcoming Albums</th>
</tr>
#for $artist in $artists
<tr>
<td align="left" width="300">
<a href="artistPage?ArtistID=$artist[1]">$artist[0]</a>
(<a class="external" href="http://musicbrainz.org/artist/$artist[1]">link</a>)
[<a class="externalred" href="deleteArtist?ArtistID=$artist[1]">delete</a>]
</td>
<td align="center" width="160">
#if $artist[2] == 'Active':
$artist[2] (<a class="external" href="pauseArtist?ArtistID=$artist[1]">pause</a>)
#else:
<font color="red"><b>$artist[2]</b></font>(<A class="external" href="resumeArtist?ArtistID=$artist[1]">resume</a>)
#end if
</td>
<td align="center">
#try
$artist[3] $artist[4]
#except
<font color="#CFCFCF">None</font>
#end try
</td>
</tr>
#end for
</table>
#include os.path.abspath($appPath+"/data/interfaces/default/_inc_footer.tmpl")

View File

@@ -0,0 +1,28 @@
#attr $path = ""
#import os.path
#include os.path.abspath($appPath+"/data/interfaces/default/_inc_header.tmpl")
<div class="config">
<h1>Import or Sync Your iTunes Library/Music Folder</h1>
<p> Enter the full path to your iTunes XML file or music folder
i.e. /Users/"username"/Music/iTunes/iTunes Music Library.xml
<i>or</i> /Users/"username"/Music/iTunes/iTunes Media/Music
(artists should have their own directories for folder import to work)
<b>note: This process can take a LONG time!</b>
Once you click "Submit" you can navigate away from this
page while the process runs. </p>
<form action="importItunes" method="GET" align="center">
<input type="text" value="${path}" onfocus="if
(this.value==this.defaultValue) this.value='';" name="path" size="70" />
<input type="submit" />
</form>
</div>
<div class="table">
<div class="config">
<h1>Force Search</h1>
<a href="forceSearch">Force Check for Wanted Albums</a><br />
<a href="forceUpdate">Force Update Active Artists </a><br />
</div>
</div>
#include os.path.abspath($appPath+"/data/interfaces/default/_inc_footer.tmpl")

View File

@@ -0,0 +1,31 @@
#import os.path
#include os.path.abspath($appPath+"/data/interfaces/default/_inc_header.tmpl")
<div id="search" style="float:left;">
<table border="0" cellpadding="3">
<form name="search">
<tr>
<td><label for="artist">Artist</label></td>
<td><input type="textbox" id="artist" /></td>
</tr>
<tr>
<td><label for="artist">Release</label></td>
<td><input type="textbox" id="artist" /></td>
</tr>
<tr>
<td><label for="artist">Label</label></td>
<td><input type="textbox" id="artist" /></td>
</tr>
<tr>
<td></td>
<td align="right"><input type="submit" value="search" onclick="$.getJSON"/></td>
</tr>
</form>
</table>
</div>
<div id="results" style="float:left;">
<b>Results:</b>
<ul id="resultsList">
<ul>
</div>
<p style="clear:both;"></p>
#include os.path.abspath($appPath+"/data/interfaces/default/_inc_footer.tmpl")

View File

@@ -0,0 +1,3 @@
#import os.path
#include os.path.abspath($appPath+"/data/interfaces/default/_inc_header.tmpl")
#include os.path.abspath($appPath+"/data/interfaces/default/_inc_footer.tmpl")

View File

@@ -106,8 +106,9 @@ def serverstart():
cherrypy.engine.subscribe('start', browser, priority=90)
logger.log(u"Starting Headphones on port:" + settings['http_port'])
cherrypy.quickstart(webServer.Headphones(), config = conf)
root = webServer.Headphones("data/interfaces/default/")
cherrypy.quickstart(root, config = conf)
if __name__ == '__main__':
serverstart()

View File

@@ -13,15 +13,22 @@ import sys
import configobj
from headphones import FULL_PATH, config_file
import logger
from Cheetah.Template import Template
database = os.path.join(FULL_PATH, 'headphones.db')
class Headphones:
def __init__(self,templatePath):
"""docstring for __init__"""
self.templatePath = templatePath
def index(self):
page = [templates._header]
page.append(templates._logobar)
page.append(templates._nav)
filename = os.path.join(self.templatePath,"index.tmpl")
template = Template(file=filename)
template.rootPath = "."
template.appPath = "."
#Display Database if it exists:
if os.path.exists(database):
#logger.log(u"Loading artists from the database...")
@@ -30,129 +37,71 @@ class Headphones:
c.execute('SELECT ArtistName, ArtistID, Status from artists order by ArtistSortName collate nocase')
results = c.fetchall()
i = 0
page.append('''<div class="table"><table border="0" cellpadding="3">
<tr>
<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>
</tr>''')
template.artists = []
while i < len(results):
c.execute('''SELECT AlbumTitle, ReleaseDate, DateAdded, AlbumID from albums WHERE ArtistID='%s' order by ReleaseDate DESC''' % results[i][1])
latestalbum = c.fetchall()
today = datetime.date.today()
if len(latestalbum) > 0:
if latestalbum[0][1] > datetime.date.isoformat(today):
newalbumName = '<font color="#5DFC0A" size="3px"><a href="albumPage?AlbumID=%s"><i>%s</i>' % (latestalbum[0][3], latestalbum[0][0])
releaseDate = '(%s)</a></font>' % latestalbum[0][1]
else:
newalbumName = '<font color="#CFCFCF">None</font>'
releaseDate = ""
if len(latestalbum) == 0:
newalbumName = '<font color="#CFCFCF">None</font>'
releaseDate = ""
if results[i][2] == 'Paused':
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="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">%s %s</td></tr>''' % (results[i][1], results[i][0], results[i][1], results[i][1], newStatus, newalbumName, releaseDate))
results[i][3] = '<font color="#CFCFCF">None</font>'
results[i][4] = ""
elif latestalbum[0][1] > datetime.date.isoformat(today):
results[i][3] = '<font color="#5DFC0A" size="3px"><a href="albumPage?AlbumID=%s"><i>%s</i>' % (latestalbum[0][3], latestalbum[0][0])
results[i][4] = '(%s)</a></font>' % latestalbum[0][1]
template.artists.append(results[i])
i = i+1
c.close()
page.append('''</table></div>''')
else:
page.append("""<div class="datanil">Add some artists to the database!</div>""")
page.append(templates._footer)
return page
return str(template)
index.exposed = True
def artistPage(self, ArtistID):
page = [templates._header]
page.append(templates._logobar)
page.append(templates._nav)
filename = os.path.join(self.templatePath,"artistPage.tmpl")
template = Template(file=filename)
template.rootPath = "."
template.appPath = "."
template.artistID = ArtistID
conn=sqlite3.connect(database)
c=conn.cursor()
c.execute('''SELECT ArtistName from artists WHERE ArtistID="%s"''' % ArtistID)
artistname = c.fetchall()
template.artistName = artistname[0]
c.execute('''SELECT AlbumTitle, ReleaseDate, AlbumID, Status, ArtistName, AlbumASIN from albums WHERE ArtistID="%s" order by ReleaseDate DESC''' % ArtistID)
results = c.fetchall()
c.close()
i = 0
page.append('''<div class="table"><table border="0" cellpadding="3">
<tr><p align="center">%s <br /></p></tr>
<tr>
<th align="left" width="50"></th>
<th align="left" width="120">Album Name</th>
<th align="center" width="100">Release Date</th>
<th align="center" width="300">Status</th>
<th> </th>
</tr>''' % (artistname[0]))
template.albums = []
while i < len(results):
if results[i][3] == 'Skipped':
newStatus = '''%s [<A class="external" href="queueAlbum?AlbumID=%s&ArtistID=%s">want</a>]''' % (results[i][3], results[i][2], ArtistID)
elif results[i][3] == 'Wanted':
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>
<td align="left" width="240"><a href="albumPage?AlbumID=%s">%s</a>
(<A class="external" href="http://musicbrainz.org/release/%s.html">link</a>)</td>
<td align="center" width="160">%s</td>
<td align="center">%s</td></tr>''' % (results[i][5], results[i][2], results[i][0], results[i][2], results[i][1], newStatus))
template.albums.append(results[i])
i = i+1
page.append('''</table></div>''')
page.append(templates._footer)
return page
return str(template)
artistPage.exposed = True
def albumPage(self, AlbumID):
page = [templates._header]
page.append(templates._logobar)
page.append(templates._nav)
filename = os.path.join(self.templatePath,"albumPage.tmpl")
template = Template(file=filename)
template.rootPath = "."
template.appPath = "."
conn=sqlite3.connect(database)
c=conn.cursor()
c.execute('''SELECT ArtistID, ArtistName, AlbumTitle, TrackTitle, TrackDuration, TrackID, AlbumASIN from tracks WHERE AlbumID="%s"''' % AlbumID)
results = c.fetchall()
if results[0][6]:
albumart = '''<br /><img src="http://ec1.images-amazon.com/images/P/%s.01.LZZZZZZZ.jpg" height="200" width="200"><br /><br />''' % results[0][6]
else:
albumart = ''
c.close()
template.albumASIN = results[0][6]
template.artistID = results[0][0]
template.artistName = results[0][1]
template.albumTitle = results[0][2]
template.tracks = []
i = 0
page.append('''<div class="table" align="center"><table border="0" cellpadding="3">
<tr><a href="artistPage?ArtistID=%s">%s</a> - %s<br />
<a href="queueAlbum?AlbumID=%s&ArtistID=%s">Download<br />%s</tr>
<br /><tr>
<th align="left" width="100">Track #</th>
<th align="left" width="100">Track Title</th>
<th align="center" width="300">Duration</th>
<th> </th>
</tr>''' % (results[0][0], results[0][1], results[0][2], AlbumID, results[0][0], albumart))
while i < len(results):
if results[i][4]:
duration = time.strftime("%M:%S", time.gmtime(int(results[i][4])/1000))
else:
duration = 'n/a'
page.append('''<tr><td align="left" width="120">%s</td>
<td align="left" width="240">%s (<A class="external" href="http://musicbrainz.org/recording/%s.html">link</a>)</td>
<td align="center">%s</td></tr>''' % (i+1, results[i][3], results[i][5], duration))
track = list(results[i])
track.append(i+1)
template.tracks.append(track)
i = i+1
page.append('''</table></div>''')
page.append(templates._footer)
return page
return str(template)
albumPage.exposed = True
@@ -182,15 +131,17 @@ class Headphones:
findArtist.exposed = True
def artistInfo(self, artistid):
page = [templates._header]
filename = os.path.join(self.templatePath,"artistInfo.tmpl")
template = Template(file=filename)
template.rootPath = "."
template.appPath = "."
inc = ws.ArtistIncludes(releases=(m.Release.TYPE_OFFICIAL, m.Release.TYPE_ALBUM), releaseGroups=True)
artist = ws.Query().getArtistById(artistid, inc)
page.append('''Artist Name: %s </br> ''' % artist.name)
page.append('''Unique ID: %s </br></br>Albums:<br />''' % u.extractUuid(artist.id))
for rg in artist.getReleaseGroups():
page.append('''%s <br />''' % rg.title)
return page
template.artistName = artist.name
template.artistUuid = artistid
template.releaseGroups = artist.getReleaseGroups()
return str(template)
artistInfo.exposed = True
def addArtist(self, artistid):
@@ -308,38 +259,25 @@ class Headphones:
unqueueAlbum.exposed = True
def upcoming(self):
page = [templates._header]
page.append(templates._logobar)
page.append(templates._nav)
page.append(templates._footer)
return page
filename = os.path.join(self.templatePath,"upcoming.tmpl")
template = Template(file=filename)
template.rootPath = "."
template.appPath = "."
return str(template)
upcoming.exposed = True
def manage(self):
filename = os.path.join(self.templatePath,"manage.tmpl")
template = Template(file=filename)
template.rootPath = "."
template.appPath = "."
config = configobj.ConfigObj(config_file)
try:
path = config['General']['path_to_xml']
except:
path = 'Absolute path to iTunes XML or Top-Level Music Directory'
page = [templates._header]
page.append(templates._logobar)
page.append(templates._nav)
page.append('''<div class="table"><div class="config"><h1>Import or Sync Your iTunes Library/Music Folder</h1><br />
Enter the full path to your iTunes XML file or music folder<br /><br />
i.e. /Users/"username"/Music/iTunes/iTunes Music Library.xml<br />
<i>or</i> /Users/"username"/Music/iTunes/iTunes Media/Music <br /><br />(artists should have their own directories for folder import to work)
<br /><br />note: This process can take a LONG time!<br /><br />
Once you click "Submit" you can navigate away from this
page while the process runs.<br /><br /><br />
<form action="importItunes" method="GET" align="center">
<input type="text" value="%s" onfocus="if
(this.value==this.defaultValue) this.value='';" name="path" size="70" />
<input type="submit" /></form><br /><br /></div></div>
<div class="table"><div class="config"><h1>Force Search</h1><br />
<a href="forceSearch">Force Check for Wanted Albums</a><br /><br />
<a href="forceUpdate">Force Update Active Artists </a><br /><br /><br /></div></div>''' % path)
page.append(templates._footer)
return page
template.path = path
return str(template)
manage.exposed = True
def importItunes(self, path):
@@ -365,21 +303,19 @@ class Headphones:
def history(self):
page = [templates._header]
page.append(templates._logobar)
page.append(templates._nav)
page.append(templates._footer)
return page
filename = os.path.join(self.templatePath,"history.tmpl")
template = Template(file=filename)
template.rootPath = "."
template.appPath = "."
return str(template)
history.exposed = True
def config(self):
page = [templates._header]
page.append(templates._logobar)
page.append(templates._nav)
page.append(config.form)
page.append(templates._footer)
return page
filename = os.path.join(self.templatePath,"config.tmpl")
template = Template(file=filename)
template.rootPath = "."
template.appPath = "."
return str(template)
config.exposed = True
@@ -445,4 +381,4 @@ class Headphones:
python = sys.executable
os.execl(python, python, * sys.argv)
restart.exposed = True
restart.exposed = True