From 6e904190143c0bcdb9efb97b7c14c3db9c4bf6a6 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Thu, 17 Apr 2014 20:44:28 -0700 Subject: [PATCH 01/27] Don't need to get commits behind if current version == latest version (versioncheck.py) --- headphones/versioncheck.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/headphones/versioncheck.py b/headphones/versioncheck.py index d8ab0f87..e7bd8fd8 100644 --- a/headphones/versioncheck.py +++ b/headphones/versioncheck.py @@ -136,6 +136,10 @@ def checkGithub(): logger.info('You are running an unknown version of Headphones. Run the updater to identify your version') return headphones.LATEST_VERSION + if headphones.LATEST_VERSION == headphones.CURRENT_VERSION: + logger.info('Headphones is up to date') + return headphones.LATEST_VERSION + logger.info('Comparing currently installed version with latest GitHub version') url = 'https://api.github.com/repos/%s/headphones/compare/%s...%s' % (headphones.GIT_USER, headphones.LATEST_VERSION, headphones.CURRENT_VERSION) commits = request.request_json(url, timeout=20, whitelist_status_code=404, validator=lambda x: type(x) == dict) From b11610faceb031c1b37a4f10e2b5ff880c3d7eb8 Mon Sep 17 00:00:00 2001 From: Jens Rogier Date: Fri, 18 Apr 2014 10:40:15 +0200 Subject: [PATCH 02/27] Fixed major mistake where tracklisting on the index would count the total tracks of the whole database when updating albums of the particular artist. --- headphones/webserve.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/headphones/webserve.py b/headphones/webserve.py index 517104ab..da747a58 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -269,7 +269,11 @@ class WebInterface(object): searcher.searchforalbum(mbid, new=True) if action == 'WantedLossless': searcher.searchforalbum(mbid, lossless=True) - myDB.action('UPDATE artists SET TotalTracks=(SELECT COUNT(*) FROM tracks, artists WHERE tracks.ArtistName = artists.ArtistName AND AlbumTitle IN (SELECT AlbumTitle FROM albums WHERE Status != "Ignored")) WHERE ArtistID=(SELECT ArtistID FROM albums WHERE AlbumID=?)', [mbid]) + if ArtistID: + ArtistIDT = ArtistID + else: + ArtistIDT = myDB.action('SELECT ArtistID FROM albums WHERE AlbumID=?', [mbid]).fetchone()[0] + myDB.action('UPDATE artists SET TotalTracks=(SELECT COUNT(*) FROM tracks WHERE ArtistID = ? AND AlbumTitle IN (SELECT AlbumTitle FROM albums WHERE Status != "Ignored")) WHERE ArtistID=(SELECT ArtistID FROM albums WHERE AlbumID=?)', [ArtistIDT, mbid]) if ArtistID: raise cherrypy.HTTPRedirect("artistPage?ArtistID=%s" % ArtistID) else: From 84ebcb84f97934de616e4b495135167413881a10 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Fri, 18 Apr 2014 11:04:52 -0700 Subject: [PATCH 03/27] Changed 'newznab' -> 'custom newznab providers' to hopefully get rid of some confusion --- data/interfaces/default/config.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 60aeaf99..3a7b4204 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -293,7 +293,7 @@
- Newznab + Custom Newznab Providers
From 06b647e30d2ec622288ff9517e384160188135b9 Mon Sep 17 00:00:00 2001 From: Roberto Romero Date: Sat, 19 Apr 2014 01:41:23 -0300 Subject: [PATCH 04/27] Fix error: AttributeError: 'module' object has no attribute 'POST' --- headphones/notifiers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/headphones/notifiers.py b/headphones/notifiers.py index a549db80..1287cb01 100644 --- a/headphones/notifiers.py +++ b/headphones/notifiers.py @@ -192,9 +192,9 @@ class XBMC: url = host + '/jsonrpc' if self.password: - response = request.request_json(url, method="POST", data=simplejson.dumps(data), headers=headers, auth=(self.username, self.password)) + response = request.request_json(url, method="post", data=simplejson.dumps(data), headers=headers, auth=(self.username, self.password)) else: - response = request.request_json(url, method="POST", data=simplejson.dumps(data), headers=headers) + response = request.request_json(url, method="post", data=simplejson.dumps(data), headers=headers) if response: return response[0]['result'] From 90016f6eda4247be8e8bf68bd25bc676613bdfc2 Mon Sep 17 00:00:00 2001 From: Jens Rogier Date: Sun, 20 Apr 2014 19:23:10 +0200 Subject: [PATCH 05/27] Cleaned up query some more --- headphones/webserve.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/webserve.py b/headphones/webserve.py index da747a58..7ec08e76 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -273,7 +273,7 @@ class WebInterface(object): ArtistIDT = ArtistID else: ArtistIDT = myDB.action('SELECT ArtistID FROM albums WHERE AlbumID=?', [mbid]).fetchone()[0] - myDB.action('UPDATE artists SET TotalTracks=(SELECT COUNT(*) FROM tracks WHERE ArtistID = ? AND AlbumTitle IN (SELECT AlbumTitle FROM albums WHERE Status != "Ignored")) WHERE ArtistID=(SELECT ArtistID FROM albums WHERE AlbumID=?)', [ArtistIDT, mbid]) + myDB.action('UPDATE artists SET TotalTracks=(SELECT COUNT(*) FROM tracks WHERE ArtistID = ? AND AlbumTitle IN (SELECT AlbumTitle FROM albums WHERE Status != "Ignored")) WHERE ArtistID = ?', [ArtistIDT, ArtistIDT]) if ArtistID: raise cherrypy.HTTPRedirect("artistPage?ArtistID=%s" % ArtistID) else: From 54c85c79518264346c14569ad5b5f4e914e46f9b Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 28 Apr 2014 15:55:42 -0700 Subject: [PATCH 06/27] Added some logging to see why postprocessor is not automatically running --- headphones/__init__.py | 1 + headphones/postprocessor.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/headphones/__init__.py b/headphones/__init__.py index b354291b..3e6e643c 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -1109,6 +1109,7 @@ def start(): SCHED.add_interval_job(versioncheck.checkGithub, minutes=CHECK_GITHUB_INTERVAL) if DOWNLOAD_SCAN_INTERVAL > 0: + logger.info("download_scan_interval is non-zero - FORTESTING") SCHED.add_interval_job(postprocessor.checkFolder, minutes=DOWNLOAD_SCAN_INTERVAL) SCHED.start() diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index d1ccbee4..e07a983f 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -32,15 +32,17 @@ postprocessor_lock = threading.Lock() def checkFolder(): + logger.info("Checking download folder - FORTESTING") with postprocessor_lock: myDB = db.DBConnection() snatched = myDB.select('SELECT * from snatched WHERE Status="Snatched"') - + logger.info("Checking snatched albums - FORTESTING") for album in snatched: + logger.info("Got an album to check for - FORTESTING") if album['FolderName']: - + logger.info("Album has a foldername: %s - FORTESTING" % album['FolderName']) if album['Kind'] == 'nzb': # We're now checking sab config options after sending to determine renaming - but we'll keep the # iterations in just in case we can't read the config for some reason @@ -56,7 +58,7 @@ def checkFolder(): nzb_album_path = os.path.join(headphones.DOWNLOAD_DIR, nzb_folder_name).encode(headphones.SYS_ENCODING, 'replace') if os.path.exists(nzb_album_path): - logger.debug('Found %s in NZB download folder. Verifying....' % album['FolderName']) + logger.info('Found %s in NZB download folder. Verifying....' % album['FolderName']) verify(album['AlbumID'], nzb_album_path, 'nzb') if album['Kind'] == 'torrent': @@ -64,9 +66,12 @@ def checkFolder(): torrent_album_path = os.path.join(headphones.DOWNLOAD_TORRENT_DIR, album['FolderName']).encode(headphones.SYS_ENCODING,'replace') if os.path.exists(torrent_album_path): - logger.debug('Found %s in torrent download folder. Verifying....' % album['FolderName']) + logger.info('Found %s in torrent download folder. Verifying....' % album['FolderName']) verify(album['AlbumID'], torrent_album_path, 'torrent') + else: + logger.info("No folder name found for " + album['Title']) + def verify(albumid, albumpath, Kind=None, forced=False): myDB = db.DBConnection() From 66d0cb4a1b5d64e5d3375315bc02d0ec8d4d1282 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 28 Apr 2014 15:56:52 -0700 Subject: [PATCH 07/27] Added some more logging to see why postprocessor is not automatically running --- headphones/postprocessor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index e07a983f..dca29f7e 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -56,7 +56,7 @@ def checkFolder(): for nzb_folder_name in nzb_album_possibilities: nzb_album_path = os.path.join(headphones.DOWNLOAD_DIR, nzb_folder_name).encode(headphones.SYS_ENCODING, 'replace') - + logger.info("Checking if %s exists" % nzb_album_path) if os.path.exists(nzb_album_path): logger.info('Found %s in NZB download folder. Verifying....' % album['FolderName']) verify(album['AlbumID'], nzb_album_path, 'nzb') @@ -64,7 +64,7 @@ def checkFolder(): if album['Kind'] == 'torrent': torrent_album_path = os.path.join(headphones.DOWNLOAD_TORRENT_DIR, album['FolderName']).encode(headphones.SYS_ENCODING,'replace') - + logger.info("Checking if %s exists" % torrent_album_path) if os.path.exists(torrent_album_path): logger.info('Found %s in torrent download folder. Verifying....' % album['FolderName']) verify(album['AlbumID'], torrent_album_path, 'torrent') From 3e5779e5ce7c7cafe3ab2dd9b5df86abaaf9ab0f Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 28 Apr 2014 19:22:28 -0700 Subject: [PATCH 08/27] more log messages for testing #1575 issue --- headphones/postprocessor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index dca29f7e..ce51a007 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -52,9 +52,9 @@ def checkFolder(): helpers.sab_replace_spaces(album['FolderName']), helpers.sab_replace_spaces(sab_replace_dots(album['FolderName'])) ] - + logger.info("Made all the nzb possibilities - FORTESTING") for nzb_folder_name in nzb_album_possibilities: - + logger.info("Trying to create bytestring path - FORTESTING") nzb_album_path = os.path.join(headphones.DOWNLOAD_DIR, nzb_folder_name).encode(headphones.SYS_ENCODING, 'replace') logger.info("Checking if %s exists" % nzb_album_path) if os.path.exists(nzb_album_path): From 3b9816f3b38e7116d580642d2fec149562fab177 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 28 Apr 2014 19:52:25 -0700 Subject: [PATCH 09/27] Took out logging messages. Took out nzb possibilities from checkFolder since we're doing it in searcher.py anyways --- headphones/__init__.py | 1 - headphones/postprocessor.py | 39 +++++++++++-------------------------- 2 files changed, 11 insertions(+), 29 deletions(-) diff --git a/headphones/__init__.py b/headphones/__init__.py index 3e6e643c..b354291b 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -1109,7 +1109,6 @@ def start(): SCHED.add_interval_job(versioncheck.checkGithub, minutes=CHECK_GITHUB_INTERVAL) if DOWNLOAD_SCAN_INTERVAL > 0: - logger.info("download_scan_interval is non-zero - FORTESTING") SCHED.add_interval_job(postprocessor.checkFolder, minutes=DOWNLOAD_SCAN_INTERVAL) SCHED.start() diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index ce51a007..b692f847 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -31,43 +31,26 @@ from headphones import logger, helpers, request, mb, music_encoder postprocessor_lock = threading.Lock() def checkFolder(): - - logger.info("Checking download folder - FORTESTING") + with postprocessor_lock: myDB = db.DBConnection() snatched = myDB.select('SELECT * from snatched WHERE Status="Snatched"') - logger.info("Checking snatched albums - FORTESTING") + for album in snatched: - logger.info("Got an album to check for - FORTESTING") if album['FolderName']: - logger.info("Album has a foldername: %s - FORTESTING" % album['FolderName']) + if album['Kind'] == 'nzb': - # We're now checking sab config options after sending to determine renaming - but we'll keep the - # iterations in just in case we can't read the config for some reason + download_dir = headphones.DOWNLOAD_DIR + else: + download_dir = headphones.DOWNLOAD_TORRENT_DIR - nzb_album_possibilities = [ album['FolderName'], - helpers.sab_replace_dots(album['FolderName']), - helpers.sab_replace_spaces(album['FolderName']), - helpers.sab_replace_spaces(sab_replace_dots(album['FolderName'])) - ] - logger.info("Made all the nzb possibilities - FORTESTING") - for nzb_folder_name in nzb_album_possibilities: - logger.info("Trying to create bytestring path - FORTESTING") - nzb_album_path = os.path.join(headphones.DOWNLOAD_DIR, nzb_folder_name).encode(headphones.SYS_ENCODING, 'replace') - logger.info("Checking if %s exists" % nzb_album_path) - if os.path.exists(nzb_album_path): - logger.info('Found %s in NZB download folder. Verifying....' % album['FolderName']) - verify(album['AlbumID'], nzb_album_path, 'nzb') - - if album['Kind'] == 'torrent': - - torrent_album_path = os.path.join(headphones.DOWNLOAD_TORRENT_DIR, album['FolderName']).encode(headphones.SYS_ENCODING,'replace') - logger.info("Checking if %s exists" % torrent_album_path) - if os.path.exists(torrent_album_path): - logger.info('Found %s in torrent download folder. Verifying....' % album['FolderName']) - verify(album['AlbumID'], torrent_album_path, 'torrent') + album_path = os.path.join(download_dir, album['FolderName']).encode(headphones.SYS_ENCODING,'replace') + logger.info("Checking if %s exists" % album_path) + if os.path.exists(album_path): + logger.info('Found "' + album['FolderName'] + '" in ' + album['Kind'] + ' download folder. Verifying....') + verify(album['AlbumID'], torrent_album_path, 'torrent') else: logger.info("No folder name found for " + album['Title']) From 900325186b76627f3173847a35101b444683a41c Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 28 Apr 2014 20:03:02 -0700 Subject: [PATCH 10/27] Url fix for pirate bay (credit to dsm1212) --- headphones/searcher.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/headphones/searcher.py b/headphones/searcher.py index c1aee71a..f4b8ada7 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -1232,6 +1232,8 @@ def searchTorrent(album, new=False, losslessOnly=False): continue else: url = item.findAll("a")[3]['href'] + if url.lower().startswith("//"): + url = "http:" + url formatted_size = re.search('Size (.*),', unicode(item)).group(1).replace(u'\xa0', ' ') size = helpers.piratesize(formatted_size) if size < maxsize and minimumseeders < seeds and url != None: From 06ee770184b9cc8630fc85f797aa8669f3318ff5 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 28 Apr 2014 20:08:22 -0700 Subject: [PATCH 11/27] Bug fix for postprocessor fix --- headphones/postprocessor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index b692f847..8bec9830 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -50,7 +50,7 @@ def checkFolder(): logger.info("Checking if %s exists" % album_path) if os.path.exists(album_path): logger.info('Found "' + album['FolderName'] + '" in ' + album['Kind'] + ' download folder. Verifying....') - verify(album['AlbumID'], torrent_album_path, 'torrent') + verify(album['AlbumID'], album_path, album['Kind']) else: logger.info("No folder name found for " + album['Title']) From ebc0b7205fedee94702c8064f9e79497f6116bf0 Mon Sep 17 00:00:00 2001 From: Kane Wallmann Date: Wed, 30 Apr 2014 19:53:59 +1000 Subject: [PATCH 12/27] Added MPC notifier, calls 'mpc update' on local machine --- data/interfaces/default/config.html | 8 ++++++++ headphones/__init__.py | 1 + headphones/notifiers.py | 11 +++++++++++ headphones/postprocessor.py | 4 ++++ headphones/webserve.py | 7 +++++-- 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 60aeaf99..44f36268 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -812,6 +812,14 @@
+
+

MPC

+
+ +
+
+ +
diff --git a/headphones/__init__.py b/headphones/__init__.py index b354291b..68edabf3 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -284,6 +284,7 @@ SONGKICK_ENABLED = False SONGKICK_APIKEY = None SONGKICK_LOCATION = None SONGKICK_FILTER_ENABLED = False +MPC_ENABLED = False CACHE_SIZEMB = 32 JOURNAL_MODE = None diff --git a/headphones/notifiers.py b/headphones/notifiers.py index a549db80..fdb12c55 100644 --- a/headphones/notifiers.py +++ b/headphones/notifiers.py @@ -169,6 +169,17 @@ class PROWL: self.notify('ZOMG Lazors Pewpewpew!', 'Test Message') +class MPC: + + def __init__(self): + + pass + + def notify( self ): + + subprocess.call( ["mpc", "update"] ) + + class XBMC: def __init__(self): diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index d1ccbee4..726c56fd 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -502,6 +502,10 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list, boxcar = notifiers.BOXCAR() boxcar.notify('Headphones processed: ' + pushmessage, "Download and Postprocessing completed", release['AlbumID']) + if headphones.MPC_ENABLED: + mpc = notifiers.MPC() + mpc.notify() + def embedAlbumArt(artwork, downloaded_track_list): logger.info('Embedding album art') diff --git a/headphones/webserve.py b/headphones/webserve.py index 517104ab..8f293ee1 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -1085,7 +1085,8 @@ class WebInterface(object): "songkick_filter_enabled": checked(headphones.SONGKICK_FILTER_ENABLED), "cache_sizemb": headphones.CACHE_SIZEMB, "file_permissions": headphones.FILE_PERMISSIONS, - "folder_permissions": headphones.FOLDER_PERMISSIONS + "folder_permissions": headphones.FOLDER_PERMISSIONS, + "mpc_enabled": checked(headphones.MPC_ENABLED) } # Need to convert EXTRAS to a dictionary we can pass to the config: it'll come in as a string like 2,5,6,8 @@ -1122,7 +1123,7 @@ class WebInterface(object): osx_notify_enabled=0, osx_notify_onsnatch=0, osx_notify_app=None, boxcar_enabled=0, boxcar_onsnatch=0, boxcar_token=None, mirror=None, customhost=None, customport=None, customsleep=None, hpuser=None, hppass=None, preferred_bitrate_high_buffer=None, preferred_bitrate_low_buffer=None, preferred_bitrate_allow_lossless=0, cache_sizemb=None, enable_https=0, https_cert=None, https_key=None, file_permissions=None, folder_permissions=None, plex_enabled=0, plex_server_host=None, plex_client_host=None, plex_username=None, plex_password=None, plex_update=0, plex_notify=0, - songkick_enabled=0, songkick_apikey=None, songkick_location=None, songkick_filter_enabled=0, encoder_multicore=False, encoder_multicore_count=0, **kwargs): + songkick_enabled=0, songkick_apikey=None, songkick_location=None, songkick_filter_enabled=0, encoder_multicore=False, encoder_multicore_count=0, mpc_enabled=False, **kwargs ): headphones.HTTP_HOST = http_host headphones.HTTP_PORT = http_port @@ -1291,6 +1292,8 @@ class WebInterface(object): headphones.BOXCAR_ONSNATCH = boxcar_onsnatch headphones.BOXCAR_TOKEN = boxcar_token + headphones.MPC_ENABLED = mpc_enabled + headphones.MIRROR = mirror headphones.CUSTOMHOST = customhost headphones.CUSTOMPORT = customport From ea8b1815f633821944c304f40f26afe872f365eb Mon Sep 17 00:00:00 2001 From: Kane Wallmann Date: Wed, 30 Apr 2014 20:18:48 +1000 Subject: [PATCH 13/27] Fixed tab indent to match file --- headphones/webserve.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/webserve.py b/headphones/webserve.py index 8f293ee1..625a7b76 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -1086,7 +1086,7 @@ class WebInterface(object): "cache_sizemb": headphones.CACHE_SIZEMB, "file_permissions": headphones.FILE_PERMISSIONS, "folder_permissions": headphones.FOLDER_PERMISSIONS, - "mpc_enabled": checked(headphones.MPC_ENABLED) + "mpc_enabled": checked(headphones.MPC_ENABLED) } # Need to convert EXTRAS to a dictionary we can pass to the config: it'll come in as a string like 2,5,6,8 From 758154e87e38d75058ddfedb33b9099063596e9f Mon Sep 17 00:00:00 2001 From: rembo10 Date: Wed, 30 Apr 2014 21:00:30 -0700 Subject: [PATCH 14/27] Some initial changes for utorrent --- data/interfaces/default/config.html | 6 +- headphones/__init__.py | 5 +- headphones/utorrent.py | 95 +++++++++++++++++++++++++++++ headphones/webserve.py | 4 +- 4 files changed, 107 insertions(+), 3 deletions(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 3a7b4204..30589755 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -192,7 +192,7 @@
Torrents - Black Hole Transmission + Black Hole Transmission uTorrent
@@ -239,6 +239,10 @@
+
+ + +
diff --git a/headphones/__init__.py b/headphones/__init__.py index b354291b..2d4e9290 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -154,6 +154,7 @@ TRANSMISSION_PASSWORD = None UTORRENT_HOST = None UTORRENT_USERNAME = None UTORRENT_PASSWORD = None +UTORRENT_LABEL = None NEWZNAB = False NEWZNAB_HOST = None @@ -346,7 +347,7 @@ def initialize(): RUTRACKER, RUTRACKER_USER, RUTRACKER_PASSWORD, WHATCD, WHATCD_USERNAME, WHATCD_PASSWORD, DOWNLOAD_TORRENT_DIR, \ LIBRARYSCAN, LIBRARYSCAN_INTERVAL, DOWNLOAD_SCAN_INTERVAL, UPDATE_DB_INTERVAL, MB_IGNORE_AGE, SAB_HOST, SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, \ NZBGET_USERNAME, NZBGET_PASSWORD, NZBGET_CATEGORY, NZBGET_HOST, HEADPHONES_INDEXER, NZBMATRIX, TRANSMISSION_HOST, TRANSMISSION_USERNAME, TRANSMISSION_PASSWORD, \ - UTORRENT_HOST, UTORRENT_USERNAME, UTORRENT_PASSWORD, NEWZNAB, NEWZNAB_HOST, NEWZNAB_APIKEY, NEWZNAB_ENABLED, EXTRA_NEWZNABS, \ + UTORRENT_HOST, UTORRENT_USERNAME, UTORRENT_PASSWORD, UTORRENT_LABEL, NEWZNAB, NEWZNAB_HOST, NEWZNAB_APIKEY, NEWZNAB_ENABLED, EXTRA_NEWZNABS, \ NZBSORG, NZBSORG_UID, NZBSORG_HASH, NZBSRUS, NZBSRUS_UID, NZBSRUS_APIKEY, OMGWTFNZBS, OMGWTFNZBS_UID, OMGWTFNZBS_APIKEY, \ NZB_DOWNLOADER, TORRENT_DOWNLOADER, PREFERRED_WORDS, REQUIRED_WORDS, IGNORED_WORDS, LASTFM_USERNAME, \ INTERFACE, FOLDER_PERMISSIONS, FILE_PERMISSIONS, ENCODERFOLDER, ENCODER_PATH, ENCODER, XLDPROFILE, BITRATE, SAMPLINGFREQUENCY, \ @@ -511,6 +512,7 @@ def initialize(): UTORRENT_HOST = check_setting_str(CFG, 'uTorrent', 'utorrent_host', '') UTORRENT_USERNAME = check_setting_str(CFG, 'uTorrent', 'utorrent_username', '') UTORRENT_PASSWORD = check_setting_str(CFG, 'uTorrent', 'utorrent_password', '') + UTORRENT_LABEL = check_setting_str(CFG, 'uTorrent', 'utorrent_label', '') NEWZNAB = bool(check_setting_int(CFG, 'Newznab', 'newznab', 0)) NEWZNAB_HOST = check_setting_str(CFG, 'Newznab', 'newznab_host', '') @@ -941,6 +943,7 @@ def config_write(): new_config['uTorrent']['utorrent_host'] = UTORRENT_HOST new_config['uTorrent']['utorrent_username'] = UTORRENT_USERNAME new_config['uTorrent']['utorrent_password'] = UTORRENT_PASSWORD + new_config['uTorrent']['utorrent_label'] = UTORRENT_LABEL new_config['Newznab'] = {} new_config['Newznab']['newznab'] = int(NEWZNAB) diff --git a/headphones/utorrent.py b/headphones/utorrent.py index fca5f5e3..5b870ea2 100644 --- a/headphones/utorrent.py +++ b/headphones/utorrent.py @@ -12,3 +12,98 @@ # # You should have received a copy of the GNU General Public License # along with Headphones. If not, see . + +import re +import time +import base64 +import headphones + +import simplejson as json + +from headphones import logger, notifiers, request + +# This is just a simple script to send torrents to transmission. The +# intention is to turn this into a class where we can check the state +# of the download, set the download dir, etc. +# TODO: Store the session id so we don't need to make 2 calls +# Store torrent id so we can check up on it + +def addTorrent(link): + method = 'torrent-add' + arguments = {'filename': link, 'download-dir': headphones.DOWNLOAD_TORRENT_DIR} + + response = torrentAction(method,arguments) + + if not response: + return False + + if response['result'] == 'success': + if 'torrent-added' in response['arguments']: + name = response['arguments']['torrent-added']['name'] + retid = response['arguments']['torrent-added']['id'] + elif 'torrent-duplicate' in response['arguments']: + name = response['arguments']['torrent-duplicate']['name'] + retid = response['arguments']['torrent-duplicate']['id'] + else: + name = link + retid = False + + logger.info(u"Torrent sent to Transmission successfully") + return retid + + else: + logger.info('Transmission returned status %s' % response['result']) + return False + +def getTorrentFolder(torrentid): + method = 'torrent-get' + arguments = { 'ids': torrentid, 'fields': ['name','percentDone']} + + response = torrentAction(method, arguments) + percentdone = response['arguments']['torrents'][0]['percentDone'] + torrent_folder_name = response['arguments']['torrents'][0]['name'] + + tries = 1 + + while percentdone == 0 and tries <10: + tries+=1 + time.sleep(5) + response = torrentAction(method, arguments) + percentdone = response['arguments']['torrents'][0]['percentDone'] + + torrent_folder_name = response['arguments']['torrents'][0]['name'] + + return torrent_folder_name + +def torrentAction(method, arguments): + + host = headphones.UTORRENT_HOST + username = headphones.UTORRENT_USERNAME + password = headphones.UTORRENT_PASSWORD + token = '' + + if not host.startswith('http'): + host = 'http://' + host + + if host.endswith('/'): + host = host[:-1] + + if host.endswith('/gui'): + host = host + '/' + else: + host = host + '/gui/' + + # Retrieve session id + auth = (username, password) if username and password else None + token_request = request.request_response(host + 'token.html') + token = re.findall('(.*?) Date: Wed, 30 Apr 2014 21:58:46 -0700 Subject: [PATCH 15/27] Slowly making progress --- headphones/searcher.py | 29 +++++++++++++++++++++++++++++ headphones/utorrent.py | 23 +++++++++++++++-------- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/headphones/searcher.py b/headphones/searcher.py index f4b8ada7..32aa5974 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -696,6 +696,35 @@ def send_to_downloader(data, bestqual, album): except Exception, e: logger.exception("Unhandled exception") + else: + logger.info("Sending torrent to uTorrent") + + # rutracker needs cookies to be set, pass the .torrent file instead of url + if bestqual[3] == 'rutracker.org': + file_or_url = rutracker.get_torrent(bestqual[2]) + else: + file_or_url = bestqual[2] + + torrentid = utorrent.addTorrent(file_or_url) + + if not torrentid: + logger.error("Error sending torrent to uTorrent. Are you sure it's running?") + return + + folder_name = utorrent.getTorrentFolder(torrentid) + if folder_name: + logger.info('Torrent folder name: %s' % folder_name) + else: + logger.error('Torrent folder name could not be determined') + return + + # remove temp .torrent file created above + if bestqual[3] == 'rutracker.org': + try: + shutil.rmtree(os.path.split(file_or_url)[0]) + except Exception, e: + logger.exception("Unhandled exception") + myDB = db.DBConnection() myDB.action('UPDATE albums SET status = "Snatched" WHERE AlbumID=?', [album['AlbumID']]) myDB.action('INSERT INTO snatched VALUES( ?, ?, ?, ?, DATETIME("NOW", "localtime"), ?, ?, ?)', [album['AlbumID'], bestqual[0], bestqual[1], bestqual[2], "Snatched", folder_name, kind]) diff --git a/headphones/utorrent.py b/headphones/utorrent.py index 5b870ea2..a1509a04 100644 --- a/headphones/utorrent.py +++ b/headphones/utorrent.py @@ -29,14 +29,23 @@ from headphones import logger, notifiers, request # Store torrent id so we can check up on it def addTorrent(link): - method = 'torrent-add' - arguments = {'filename': link, 'download-dir': headphones.DOWNLOAD_TORRENT_DIR} - response = torrentAction(method,arguments) + if link.startswith("magnet") or link.startswith("http") or link.endswith(".torrent"): + method = None + params = {'action':'add-url', 's':link} + files = None + else: + method = "post" + params = {'action':'add-file'} + files = {'torrent_file':{'music.torrent', link}} + + response = torrentAction(method,params,files) if not response: return False + print response + if response['result'] == 'success': if 'torrent-added' in response['arguments']: name = response['arguments']['torrent-added']['name'] @@ -75,7 +84,7 @@ def getTorrentFolder(torrentid): return torrent_folder_name -def torrentAction(method, arguments): +def torrentAction(method=None, params=None, files=None): host = headphones.UTORRENT_HOST username = headphones.UTORRENT_USERNAME @@ -98,12 +107,10 @@ def torrentAction(method, arguments): token_request = request.request_response(host + 'token.html') token = re.findall('(.*?) Date: Wed, 30 Apr 2014 22:38:20 -0700 Subject: [PATCH 16/27] fixin some bugs --- headphones/utorrent.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/headphones/utorrent.py b/headphones/utorrent.py index a1509a04..97fe1219 100644 --- a/headphones/utorrent.py +++ b/headphones/utorrent.py @@ -45,7 +45,7 @@ def addTorrent(link): return False print response - + if response['result'] == 'success': if 'torrent-added' in response['arguments']: name = response['arguments']['torrent-added']['name'] @@ -104,8 +104,8 @@ def torrentAction(method=None, params=None, files=None): # Retrieve session id auth = (username, password) if username and password else None - token_request = request.request_response(host + 'token.html') - token = re.findall('(.*?)(.*?) Date: Thu, 1 May 2014 00:02:29 -0700 Subject: [PATCH 17/27] Some changes. Getting close --- data/interfaces/default/config.html | 4 +- headphones/searcher.py | 9 +-- headphones/utorrent.py | 98 ++++++++++++----------------- 3 files changed, 43 insertions(+), 68 deletions(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 30589755..54f513f7 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -124,7 +124,7 @@
Usenet - Sabnzbd NZBget Black Hole + Sabnzbd NZBget Black Hole
@@ -192,7 +192,7 @@
Torrents - Black Hole Transmission uTorrent + Black Hole Transmission uTorrent (Beta)
diff --git a/headphones/searcher.py b/headphones/searcher.py index 32aa5974..ecc92acb 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -705,13 +705,8 @@ def send_to_downloader(data, bestqual, album): else: file_or_url = bestqual[2] - torrentid = utorrent.addTorrent(file_or_url) - - if not torrentid: - logger.error("Error sending torrent to uTorrent. Are you sure it's running?") - return - - folder_name = utorrent.getTorrentFolder(torrentid) + folder_name = utorrent.addTorrent(bestqual[2],bestqual[0]) + if folder_name: logger.info('Torrent folder name: %s' % folder_name) else: diff --git a/headphones/utorrent.py b/headphones/utorrent.py index 97fe1219..e8fb4809 100644 --- a/headphones/utorrent.py +++ b/headphones/utorrent.py @@ -14,6 +14,7 @@ # along with Headphones. If not, see . import re +import os import time import base64 import headphones @@ -28,67 +29,13 @@ from headphones import logger, notifiers, request # TODO: Store the session id so we don't need to make 2 calls # Store torrent id so we can check up on it -def addTorrent(link): - if link.startswith("magnet") or link.startswith("http") or link.endswith(".torrent"): - method = None - params = {'action':'add-url', 's':link} - files = None - else: - method = "post" - params = {'action':'add-file'} - files = {'torrent_file':{'music.torrent', link}} - - response = torrentAction(method,params,files) - - if not response: - return False - - print response - - if response['result'] == 'success': - if 'torrent-added' in response['arguments']: - name = response['arguments']['torrent-added']['name'] - retid = response['arguments']['torrent-added']['id'] - elif 'torrent-duplicate' in response['arguments']: - name = response['arguments']['torrent-duplicate']['name'] - retid = response['arguments']['torrent-duplicate']['id'] - else: - name = link - retid = False - - logger.info(u"Torrent sent to Transmission successfully") - return retid - - else: - logger.info('Transmission returned status %s' % response['result']) - return False - -def getTorrentFolder(torrentid): - method = 'torrent-get' - arguments = { 'ids': torrentid, 'fields': ['name','percentDone']} - - response = torrentAction(method, arguments) - percentdone = response['arguments']['torrents'][0]['percentDone'] - torrent_folder_name = response['arguments']['torrents'][0]['name'] - - tries = 1 - - while percentdone == 0 and tries <10: - tries+=1 - time.sleep(5) - response = torrentAction(method, arguments) - percentdone = response['arguments']['torrents'][0]['percentDone'] - - torrent_folder_name = response['arguments']['torrents'][0]['name'] - - return torrent_folder_name - -def torrentAction(method=None, params=None, files=None): +def addTorrent(link, title): host = headphones.UTORRENT_HOST username = headphones.UTORRENT_USERNAME password = headphones.UTORRENT_PASSWORD + label = headphones.UTORRENT_LABEL token = '' if not host.startswith('http'): @@ -106,11 +53,44 @@ def torrentAction(method=None, params=None, files=None): auth = (username, password) if username and password else None token_request = request.request_response(host + 'token.html', auth=auth) token = re.findall('(.*?) 1: + folder = os.path.basename(torrent[26]) + tor_hash = torrent[0] + params = {'action':'setprops', 'hash':tor_hash,'s':'label', 'v':label} + response = request.request_json(host, params=params, auth=auth, cookies=cookies) + break + else: + time.sleep(5) + tries += 1 + + return folder + + From 1f3474a1549a23b06092ecd10667de3b55350f87 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Thu, 1 May 2014 00:06:25 -0700 Subject: [PATCH 18/27] bug fix --- headphones/searcher.py | 4 ++-- headphones/utorrent.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/headphones/searcher.py b/headphones/searcher.py index ecc92acb..c89720b3 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -705,8 +705,8 @@ def send_to_downloader(data, bestqual, album): else: file_or_url = bestqual[2] - folder_name = utorrent.addTorrent(bestqual[2],bestqual[0]) - + folder_name = utorrent.addTorrent(file_or_url,bestqual[0]) + if folder_name: logger.info('Torrent folder name: %s' % folder_name) else: diff --git a/headphones/utorrent.py b/headphones/utorrent.py index e8fb4809..ee14849b 100644 --- a/headphones/utorrent.py +++ b/headphones/utorrent.py @@ -84,7 +84,7 @@ def addTorrent(link, title): if torrent[2] == title and torrent[4] > 1: folder = os.path.basename(torrent[26]) tor_hash = torrent[0] - params = {'action':'setprops', 'hash':tor_hash,'s':'label', 'v':label} + params = {'action':'setprops', 'hash':tor_hash,'s':'label', 'v':label, token':token} response = request.request_json(host, params=params, auth=auth, cookies=cookies) break else: From 0c7ea8a5a0e8e38a3c6499cef0212013b9860515 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Thu, 1 May 2014 00:09:45 -0700 Subject: [PATCH 19/27] typo --- headphones/utorrent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/utorrent.py b/headphones/utorrent.py index ee14849b..e11dc958 100644 --- a/headphones/utorrent.py +++ b/headphones/utorrent.py @@ -84,7 +84,7 @@ def addTorrent(link, title): if torrent[2] == title and torrent[4] > 1: folder = os.path.basename(torrent[26]) tor_hash = torrent[0] - params = {'action':'setprops', 'hash':tor_hash,'s':'label', 'v':label, token':token} + params = {'action':'setprops', 'hash':tor_hash,'s':'label', 'v':label, 'token':token} response = request.request_json(host, params=params, auth=auth, cookies=cookies) break else: From e155f19d0d2954cac875751bc422f641b37c565a Mon Sep 17 00:00:00 2001 From: rembo10 Date: Thu, 1 May 2014 00:14:10 -0700 Subject: [PATCH 20/27] Debug logging --- headphones/utorrent.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/headphones/utorrent.py b/headphones/utorrent.py index e11dc958..ce39020a 100644 --- a/headphones/utorrent.py +++ b/headphones/utorrent.py @@ -37,7 +37,7 @@ def addTorrent(link, title): password = headphones.UTORRENT_PASSWORD label = headphones.UTORRENT_LABEL token = '' - + logger.info("2") if not host.startswith('http'): host = 'http://' + host @@ -52,18 +52,22 @@ def addTorrent(link, title): # Retrieve session id auth = (username, password) if username and password else None token_request = request.request_response(host + 'token.html', auth=auth) + logger.info("3") token = re.findall('(.*?) Date: Thu, 1 May 2014 00:28:50 -0700 Subject: [PATCH 21/27] Took out debug logging, put the torrent checking in the right place --- headphones/searcher.py | 2 +- headphones/utorrent.py | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/headphones/searcher.py b/headphones/searcher.py index c89720b3..6207551e 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -31,7 +31,7 @@ import subprocess import headphones from headphones.common import USER_AGENT from headphones import logger, db, helpers, classes, sab, nzbget, request -from headphones import transmission, notifiers +from headphones import utorrent, transmission, notifiers import lib.bencode as bencode diff --git a/headphones/utorrent.py b/headphones/utorrent.py index ce39020a..ff313589 100644 --- a/headphones/utorrent.py +++ b/headphones/utorrent.py @@ -37,7 +37,7 @@ def addTorrent(link, title): password = headphones.UTORRENT_PASSWORD label = headphones.UTORRENT_LABEL token = '' - logger.info("2") + if not host.startswith('http'): host = 'http://' + host @@ -52,19 +52,16 @@ def addTorrent(link, title): # Retrieve session id auth = (username, password) if username and password else None token_request = request.request_response(host + 'token.html', auth=auth) - logger.info("3") + token = re.findall('(.*?) 1: folder = os.path.basename(torrent[26]) From 9c2da72dccd26897a2fa1c4225e39de1686376c6 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Thu, 1 May 2014 01:09:26 -0700 Subject: [PATCH 22/27] Bug fixes to get utorrent working --- headphones/searcher.py | 4 ++-- headphones/utorrent.py | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/headphones/searcher.py b/headphones/searcher.py index 6207551e..42e124d8 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -705,7 +705,7 @@ def send_to_downloader(data, bestqual, album): else: file_or_url = bestqual[2] - folder_name = utorrent.addTorrent(file_or_url,bestqual[0]) + folder_name = utorrent.addTorrent(file_or_url) if folder_name: logger.info('Torrent folder name: %s' % folder_name) @@ -1450,4 +1450,4 @@ def preprocess(resultlist): logger.error("Couldn't retrieve the best nzb. Skipping.") continue - return (None, None) \ No newline at end of file + return (None, None) diff --git a/headphones/utorrent.py b/headphones/utorrent.py index ff313589..7be48355 100644 --- a/headphones/utorrent.py +++ b/headphones/utorrent.py @@ -30,7 +30,7 @@ from headphones import logger, notifiers, request # Store torrent id so we can check up on it -def addTorrent(link, title): +def addTorrent(link): host = headphones.UTORRENT_HOST username = headphones.UTORRENT_USERNAME @@ -72,27 +72,32 @@ def addTorrent(link, title): # Not really sure how to ID these? Title seems safest) # Also, not sure when the torrent will pop up in the list, so we'll make sure it exists and is 1% downloaded tries = 0 + folder = None while tries < 10: # NOW WE WILL CHECK UTORRENT FOR THE FOLDER NAME & SET THE LABEL params = {'list':'1', 'token':token} response = request.request_json(host, params=params, auth=auth, cookies=cookies) + if not response: logger.error("Error getting torrent information from uTorrent") - time.sleep(5) - continue + return for torrent in response['torrents']: - if torrent[2] == title and torrent[4] > 1: + + if torrent[19] == link and torrent[4] > 1: folder = os.path.basename(torrent[26]) tor_hash = torrent[0] params = {'action':'setprops', 'hash':tor_hash,'s':'label', 'v':label, 'token':token} response = request.request_json(host, params=params, auth=auth, cookies=cookies) break - else: - time.sleep(5) - tries += 1 + + if folder: + break + else: + time.sleep(5) + tries += 1 return folder From 5c381b941061d36d3e4ccae40d76b3edfccc3e85 Mon Sep 17 00:00:00 2001 From: delphiactual Date: Thu, 1 May 2014 21:58:05 -0600 Subject: [PATCH 23/27] Added Labeling based off of hash for utorrent and fixed a typo in postprocessor.py --- headphones/postprocessor.py | 2 +- headphones/utorrent.py | 50 ++++++++++++++++--------------------- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index 8bec9830..db5019e1 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -352,7 +352,7 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list, headphones.MOVE_FILES: if not os.access(downloaded_track, os.W_OK): - logger.error("Track file is not writeable, which is equired for some post processing steps: %s", downloaded_track.decode(headphones.SYS_ENCODING, 'replace')) + logger.error("Track file is not writeable, which is required for some post processing steps: %s", downloaded_track.decode(headphones.SYS_ENCODING, 'replace')) return #start encoding diff --git a/headphones/utorrent.py b/headphones/utorrent.py index 7be48355..7aad16f5 100644 --- a/headphones/utorrent.py +++ b/headphones/utorrent.py @@ -69,36 +69,30 @@ def addTorrent(link): logger.error("Error sending torrent to uTorrent") return - # Not really sure how to ID these? Title seems safest) - # Also, not sure when the torrent will pop up in the list, so we'll make sure it exists and is 1% downloaded - tries = 0 - folder = None - while tries < 10: + if link.startswith('magnet'): + tor_hash = re.findall('urn:btih:([\w]{32,40})', link)[0] + if len(tor_hash) == 32: + tor_hash = b16encode(b32decode(tor_hash)).lower() + else: + info = bdecode(link.content)["info"] + tor_hash = sha1(bencode(info)).hexdigest() + + params = {'action':'setprops', 'hash':tor_hash,'s':'label', 'v':label, 'token':token} + response = request.request_json(host, params=params, auth=auth, cookies=cookies) + if not response: + logger.error("Error setting torrent label in uTorrent") + return - # NOW WE WILL CHECK UTORRENT FOR THE FOLDER NAME & SET THE LABEL - params = {'list':'1', 'token':token} + # folder info can probably be cleaned up with getprops + folder = None - response = request.request_json(host, params=params, auth=auth, cookies=cookies) - - if not response: - logger.error("Error getting torrent information from uTorrent") - return + params = {'list':'1', 'token':token} + response = request.request_json(host, params=params, auth=auth, cookies=cookies) + if not response: + logger.error("Error getting torrent information from uTorrent") + return for torrent in response['torrents']: + folder = os.path.basename(torrent[26]) - if torrent[19] == link and torrent[4] > 1: - folder = os.path.basename(torrent[26]) - tor_hash = torrent[0] - params = {'action':'setprops', 'hash':tor_hash,'s':'label', 'v':label, 'token':token} - response = request.request_json(host, params=params, auth=auth, cookies=cookies) - break - - if folder: - break - else: - time.sleep(5) - tries += 1 - - return folder - - + return folder \ No newline at end of file From 084181a9a54951a7ec30b447799b9f60227daa8f Mon Sep 17 00:00:00 2001 From: delphiactual Date: Fri, 2 May 2014 00:46:20 -0600 Subject: [PATCH 24/27] password field --- data/interfaces/default/config.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 54f513f7..212d1ca5 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -237,7 +237,7 @@
- +
From a0755d4b1cbcf63246b5c5233125d06d4b815405 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Sat, 3 May 2014 18:38:16 -0700 Subject: [PATCH 25/27] Headphones indexer changes --- headphones/searcher.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/headphones/searcher.py b/headphones/searcher.py index 42e124d8..20b5f16b 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -307,13 +307,13 @@ def searchNZB(album, new=False, losslessOnly=False): params = { "t": "search", "cat": categories, - "apikey": '89edf227c1de9b3de50383fff11466c6', + "apikey": '964d601959918a578a670984bdee9357', "maxage": headphones.USENET_RETENTION, "q": term } data = request.request_feed( - url="http://headphones.codeshy.com/newznab/api", + url="http://indexer.codeshy.com/api", params=params, headers=headers, auth=(headphones.HPUSER, headphones.HPPASS) ) From 585f5560067fb3359b1b5618469e6b11f02f34e1 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 5 May 2014 14:26:44 -0700 Subject: [PATCH 26/27] Fix for #1598: Active artist update no longer updates any existing release groups --- headphones/importer.py | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/headphones/importer.py b/headphones/importer.py index 79026040..370c0268 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -226,15 +226,11 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False): skip_log = 0 #Make a user configurable variable to skip update of albums with release dates older than this date (in days) pause_delta = headphones.MB_IGNORE_AGE - - check_release_date = myDB.action("SELECT ReleaseDate, Status from albums WHERE ArtistID=? AND AlbumTitle=?", (artistid, al_title)).fetchone() - - #Skip update if Status set - if check_release_date and check_release_date[1]: - logger.info("[%s] Not updating: %s (Status is %s, skipping)" % (artist['artist_name'], rg['title'], check_release_date[1])) - continue + + rg_exists = myDB.action("SELECT * from albums WHERE AlbumID=?", [rg['id']]).fetchone() if not forcefull: + check_release_date = myDB.action("SELECT ReleaseDate from albums WHERE ArtistID=? AND AlbumTitle=?", (artistid, al_title)).fetchone() if check_release_date: if check_release_date[0] is None: logger.info("[%s] Now updating: %s (No Release Date)" % (artist['artist_name'], rg['title'])) @@ -268,11 +264,6 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False): logger.info("[%s] Now adding/updating: %s (Comprehensive Force)" % (artist['artist_name'], rg['title'])) new_releases = mb.get_new_releases(rgid,includeExtras,forcefull) - #What this does is adds new releases per artist to the allalbums + alltracks databases - #new_releases = mb.get_new_releases(rgid,includeExtras) - #print al_title - #print new_releases - if new_releases != 0: #Dump existing hybrid release since we're repackaging/replacing it myDB.action("DELETE from albums WHERE ReleaseID=?", [rg['id']]) @@ -381,7 +372,7 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False): # If there's no release in the main albums tables, add the default (hybrid) # If there is a release, check the ReleaseID against the AlbumID to see if they differ (user updated) # check if the album already exists - rg_exists = myDB.action("SELECT * from albums WHERE AlbumID=?", [rg['id']]).fetchone() + if not rg_exists: releaseid = rg['id'] else: @@ -402,11 +393,14 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False): "ReleaseFormat": album['ReleaseFormat'] } - if not rg_exists: - + if rg_exists: + newValueDict['DateAdded'] = rg_exists['DateAdded'] + newValueDict['Status'] = rg_exists['Status'] + + else: today = helpers.today() - newValueDict['DateAdded']= today + newValueDict['DateAdded'] = today if headphones.AUTOWANT_ALL: newValueDict['Status'] = "Wanted" From 497fafb555f96c6f6180f0816046002dabd5df62 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 5 May 2014 15:09:58 -0700 Subject: [PATCH 27/27] Don't need to query the db twice --- headphones/importer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/importer.py b/headphones/importer.py index 370c0268..c442ff07 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -230,7 +230,7 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False): rg_exists = myDB.action("SELECT * from albums WHERE AlbumID=?", [rg['id']]).fetchone() if not forcefull: - check_release_date = myDB.action("SELECT ReleaseDate from albums WHERE ArtistID=? AND AlbumTitle=?", (artistid, al_title)).fetchone() + check_release_date = rg_exists['ReleaseDate'] if check_release_date: if check_release_date[0] is None: logger.info("[%s] Now updating: %s (No Release Date)" % (artist['artist_name'], rg['title']))