diff --git a/configcreate.py b/configcreate.py index 804bf3c5..015a83f3 100644 --- a/configcreate.py +++ b/configcreate.py @@ -8,7 +8,7 @@ def configCreate(path): config['General']['http_port'] = 8181 config['General']['http_username'] = '' config['General']['http_password'] = '' - config['General']['launch_browser'] = 0 + config['General']['launch_browser'] = 1 config['General']['include_lossless'] = 0 config['General']['flac_to_mp3'] = 0 config['General']['move_to_itunes'] = 0 diff --git a/mover.py b/mover.py new file mode 100644 index 00000000..4bc4858c --- /dev/null +++ b/mover.py @@ -0,0 +1,21 @@ +import glob, os, shutil +from configobj import ConfigObj +from headphones import config_file + +config = ConfigObj(config_file) + +General = config['General'] +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'] + +def moveFiles(): + for root, dirs, files in os.walk(music_download_dir): + for file in files: + if file[-4:].lower() == '.mp3' and os.path.isfile(file): + print file + shutil.copy2(os.path.join(root, file), + os.path.join(path_to_itunes, file)) diff --git a/searcher.py b/searcher.py index 46b01b56..2eb25ebd 100644 --- a/searcher.py +++ b/searcher.py @@ -1,12 +1,12 @@ import urllib -from webServer import database +from webServer import database, config_file from configobj import ConfigObj import string import feedparser import sqlite3 import re -config = ConfigObj('config.ini') +config = ConfigObj(config_file) General = config['General'] NZBMatrix = config['NZBMatrix'] SABnzbd = config['SABnzbd'] @@ -95,8 +95,8 @@ def searchNZB(albumid=None): urllib.urlopen(saburl) c.execute('UPDATE albums SET status = "Snatched" WHERE AlbumID="%s"' % albums[2]) - c.execute('CREATE TABLE IF NOT EXISTS snatched (Title TEXT UNIQUE, Size INTEGER, URL TEXT, DateAdded TEXT)') - c.execute('INSERT INTO snatched VALUES( ?, ?, ?, CURRENT_DATE)', (bestqual[0], bestqual[1], bestqual[2])) + c.execute('CREATE TABLE IF NOT EXISTS snatched (AlbumID, Title TEXT UNIQUE, Size INTEGER, URL TEXT, DateAdded TEXT, Status TEXT)') + c.execute('INSERT INTO snatched VALUES( ?, ?, ?, ?, CURRENT_DATE, ?)', (albums[2], bestqual[0], bestqual[1], bestqual[2], "Snatched")) conn.commit() else: diff --git a/webServer.py b/webServer.py index d10ae9b2..6cd26484 100644 --- a/webServer.py +++ b/webServer.py @@ -7,6 +7,7 @@ import musicbrainz2.utils as u import os import string import time +import datetime import sqlite3 import sys import configobj @@ -24,7 +25,7 @@ class Headphones: if os.path.exists(database): conn=sqlite3.connect(database) c=conn.cursor() - c.execute('SELECT ArtistName, ArtistID, Status from artists order by ArtistSortName') + c.execute('SELECT ArtistName, ArtistID, Status from artists order by ArtistSortName collate nocase') results = c.fetchall() c.close() i = 0 @@ -38,8 +39,9 @@ class Headphones: while i < len(results): 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 = '%s' % (latestalbum[0][3], latestalbum[0][0]) + today = datetime.date.today() + if latestalbum[0][1] > datetime.date.isoformat(today): + newalbumName = '%s' % (latestalbum[0][3], latestalbum[0][0]) releaseDate = '(%s)' % latestalbum[0][1] else: newalbumName = 'None' @@ -128,9 +130,13 @@ class Headphones: ''' % (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('''%s %s (link) - %s''' % (i+1, results[i][3], results[i][5], time.strftime("%M:%S", time.gmtime(int(results[i][4])/1000)))) + %s''' % (i+1, results[i][3], results[i][5], duration)) i = i+1 page.append('''''') @@ -325,7 +331,7 @@ class Headphones: config.exposed = True - def configUpdate(self, http_host='127.0.0.1', 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=1, 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, flac_to_mp3=0, move_to_itunes=0, path_to_itunes=None, rename_mp3s=0, cleanup=0, add_album_art=0):