mirror of
https://github.com/rembo10/headphones.git
synced 2026-09-10 08:41:41 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a805a01f3 | ||
|
|
579b5a2f2f | ||
|
|
f10d1834dd | ||
|
|
b4c7ed2227 | ||
|
|
0086980b1b | ||
|
|
89e1793978 | ||
|
|
5a598fe611 | ||
|
|
b58f670694 | ||
|
|
5103436d17 | ||
|
|
c9a1796e56 | ||
|
|
7428b56dd5 | ||
|
|
42294d261d | ||
|
|
31a99a908a | ||
|
|
aa503f0fe8 | ||
|
|
d3d48d27df | ||
|
|
bd8eb74662 | ||
|
|
99680e9a0f | ||
|
|
0cc58bdb46 | ||
|
|
09435b8786 | ||
|
|
5d2753a34e | ||
|
|
8eb3ece2f9 | ||
|
|
d3584a5ae9 | ||
|
|
c0c64621e6 | ||
|
|
323d364572 | ||
|
|
9a681a9422 | ||
|
|
a7a709df51 | ||
|
|
3f23b5553a | ||
|
|
5a2082ede5 | ||
|
|
e29f3a0a9a | ||
|
|
f4bebf6a41 | ||
|
|
564df8136c |
@@ -1,5 +1,27 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v0.5.17
|
||||||
|
Released 10 November 2016
|
||||||
|
|
||||||
|
Highlights:
|
||||||
|
* Added: t411 support
|
||||||
|
* Fixed: Rutracker login
|
||||||
|
* Fixed: Deluge empty password
|
||||||
|
* Fixed: FreeBSD init script
|
||||||
|
* Improved: Musicbrainz searching
|
||||||
|
|
||||||
|
The full list of commits can be found [here](https://github.com/rembo10/headphones/compare/v0.5.16...v0.5.17).
|
||||||
|
|
||||||
|
## v0.5.16
|
||||||
|
Released 10 June 2016
|
||||||
|
|
||||||
|
Hotfix update
|
||||||
|
|
||||||
|
Highlights:
|
||||||
|
* Fixed: Waffles url
|
||||||
|
|
||||||
|
The full list of commits can be found [here](https://github.com/rembo10/headphones/compare/v0.5.15...v0.5.16).
|
||||||
|
|
||||||
## v0.5.15
|
## v0.5.15
|
||||||
Released 07 June 2016
|
Released 07 June 2016
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -81,6 +81,8 @@ def main():
|
|||||||
help='Prevent browser from launching on startup')
|
help='Prevent browser from launching on startup')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--pidfile', help='Create a pid file (only relevant when running as a daemon)')
|
'--pidfile', help='Create a pid file (only relevant when running as a daemon)')
|
||||||
|
parser.add_argument(
|
||||||
|
'--host', help='Specify a host (default - localhost)')
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@@ -170,6 +172,13 @@ def main():
|
|||||||
else:
|
else:
|
||||||
http_port = int(headphones.CONFIG.HTTP_PORT)
|
http_port = int(headphones.CONFIG.HTTP_PORT)
|
||||||
|
|
||||||
|
# Force the http host if neccessary
|
||||||
|
if args.host:
|
||||||
|
http_host = args.host
|
||||||
|
logger.info('Using forced web server host: %s', http_host)
|
||||||
|
else:
|
||||||
|
http_host = headphones.CONFIG.HTTP_HOST
|
||||||
|
|
||||||
# Check if pyOpenSSL is installed. It is required for certificate generation
|
# Check if pyOpenSSL is installed. It is required for certificate generation
|
||||||
# and for CherryPy.
|
# and for CherryPy.
|
||||||
if headphones.CONFIG.ENABLE_HTTPS:
|
if headphones.CONFIG.ENABLE_HTTPS:
|
||||||
@@ -183,7 +192,7 @@ def main():
|
|||||||
# Try to start the server. Will exit here is address is already in use.
|
# Try to start the server. Will exit here is address is already in use.
|
||||||
web_config = {
|
web_config = {
|
||||||
'http_port': http_port,
|
'http_port': http_port,
|
||||||
'http_host': headphones.CONFIG.HTTP_HOST,
|
'http_host': http_host,
|
||||||
'http_root': headphones.CONFIG.HTTP_ROOT,
|
'http_root': headphones.CONFIG.HTTP_ROOT,
|
||||||
'http_proxy': headphones.CONFIG.HTTP_PROXY,
|
'http_proxy': headphones.CONFIG.HTTP_PROXY,
|
||||||
'enable_https': headphones.CONFIG.ENABLE_HTTPS,
|
'enable_https': headphones.CONFIG.ENABLE_HTTPS,
|
||||||
|
|||||||
@@ -744,6 +744,22 @@
|
|||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<div class="row checkbox left">
|
||||||
|
<input id="use_tquattrecentonze" type="checkbox" class="bigcheck" name="use_tquattrecentonze" value="1" ${config['use_tquattrecentonze']} /><label for="use_tquattrecentonze"><span class="option">t411</span></label>
|
||||||
|
</div>
|
||||||
|
<div class="config">
|
||||||
|
<div class="row">
|
||||||
|
<label>Username</label>
|
||||||
|
<input type="text" name="tquattrecentonze_user" value="${config['tquattrecentonze_user']}" size="36">
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label>Password</label>
|
||||||
|
<input type="password" name="tquattrecentonze_password" value="${config['tquattrecentonze_password']}" size="36">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -2400,6 +2416,7 @@
|
|||||||
initConfigCheckbox("#api_enabled");
|
initConfigCheckbox("#api_enabled");
|
||||||
initConfigCheckbox("#enable_https");
|
initConfigCheckbox("#enable_https");
|
||||||
initConfigCheckbox("#customauth");
|
initConfigCheckbox("#customauth");
|
||||||
|
initConfigCheckbox("#use_tquattrecentonze");
|
||||||
|
|
||||||
|
|
||||||
$('#twitterStep1').click(function () {
|
$('#twitterStep1').click(function () {
|
||||||
|
|||||||
@@ -274,6 +274,9 @@ _CONFIG_DEFINITIONS = {
|
|||||||
'TWITTER_PASSWORD': (str, 'Twitter', ''),
|
'TWITTER_PASSWORD': (str, 'Twitter', ''),
|
||||||
'TWITTER_PREFIX': (str, 'Twitter', 'Headphones'),
|
'TWITTER_PREFIX': (str, 'Twitter', 'Headphones'),
|
||||||
'TWITTER_USERNAME': (str, 'Twitter', ''),
|
'TWITTER_USERNAME': (str, 'Twitter', ''),
|
||||||
|
'TQUATTRECENTONZE': (int, 'tquattrecentonze', 0),
|
||||||
|
'TQUATTRECENTONZE_PASSWORD': (str, 'tquattrecentonze', ''),
|
||||||
|
'TQUATTRECENTONZE_USER': (str, 'tquattrecentonze', ''),
|
||||||
'UPDATE_DB_INTERVAL': (int, 'General', 24),
|
'UPDATE_DB_INTERVAL': (int, 'General', 24),
|
||||||
'USENET_RETENTION': (int, 'General', '1500'),
|
'USENET_RETENTION': (int, 'General', '1500'),
|
||||||
'UTORRENT_HOST': (str, 'uTorrent', ''),
|
'UTORRENT_HOST': (str, 'uTorrent', ''),
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import pprint
|
||||||
|
import sys
|
||||||
|
import threading
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
from headphones import logger
|
||||||
|
|
||||||
|
|
||||||
|
def cry():
|
||||||
|
"""
|
||||||
|
Logs thread traces.
|
||||||
|
"""
|
||||||
|
tmap = {}
|
||||||
|
main_thread = None
|
||||||
|
# get a map of threads by their ID so we can print their names
|
||||||
|
# during the traceback dump
|
||||||
|
for t in threading.enumerate():
|
||||||
|
if t.ident:
|
||||||
|
tmap[t.ident] = t
|
||||||
|
else:
|
||||||
|
main_thread = t
|
||||||
|
|
||||||
|
# Loop over each thread's current frame, writing info about it
|
||||||
|
for tid, frame in sys._current_frames().iteritems():
|
||||||
|
thread = tmap.get(tid, main_thread)
|
||||||
|
|
||||||
|
lines = []
|
||||||
|
lines.append('%s\n' % thread.getName())
|
||||||
|
lines.append('========================================\n')
|
||||||
|
lines += traceback.format_stack(frame)
|
||||||
|
lines.append('========================================\n')
|
||||||
|
lines.append('LOCAL VARIABLES:\n')
|
||||||
|
lines.append('========================================\n')
|
||||||
|
lines.append(pprint.pformat(frame.f_locals))
|
||||||
|
lines.append('\n\n')
|
||||||
|
logger.info("".join(lines))
|
||||||
@@ -269,7 +269,8 @@ def _get_auth():
|
|||||||
delugeweb_host = headphones.CONFIG.DELUGE_HOST
|
delugeweb_host = headphones.CONFIG.DELUGE_HOST
|
||||||
delugeweb_cert = headphones.CONFIG.DELUGE_CERT
|
delugeweb_cert = headphones.CONFIG.DELUGE_CERT
|
||||||
delugeweb_password = headphones.CONFIG.DELUGE_PASSWORD
|
delugeweb_password = headphones.CONFIG.DELUGE_PASSWORD
|
||||||
logger.debug('Deluge: Using password %s******%s' % (delugeweb_password[0], delugeweb_password[-1]))
|
if len(delugeweb_password) > 0:
|
||||||
|
logger.debug('Deluge: Using password %s******%s' % (delugeweb_password[0], delugeweb_password[-1]))
|
||||||
|
|
||||||
if not delugeweb_host.startswith('http'):
|
if not delugeweb_host.startswith('http'):
|
||||||
delugeweb_host = 'http://%s' % delugeweb_host
|
delugeweb_host = 'http://%s' % delugeweb_host
|
||||||
|
|||||||
@@ -251,6 +251,7 @@ _XLATE_SPECIAL = {
|
|||||||
# Translation table.
|
# Translation table.
|
||||||
# Cover additional special characters processing normalization.
|
# Cover additional special characters processing normalization.
|
||||||
u"'": '', # replace apostrophe with nothing
|
u"'": '', # replace apostrophe with nothing
|
||||||
|
u"’": '', # replace musicbrainz style apostrophe with nothing
|
||||||
u'&': ' and ', # expand & to ' and '
|
u'&': ' and ', # expand & to ' and '
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-22
@@ -91,10 +91,6 @@ def findArtist(name, limit=1):
|
|||||||
artistlist = []
|
artistlist = []
|
||||||
artistResults = None
|
artistResults = None
|
||||||
|
|
||||||
chars = set('!?*-')
|
|
||||||
if any((c in chars) for c in name):
|
|
||||||
name = '"' + name + '"'
|
|
||||||
|
|
||||||
criteria = {'artist': name.lower()}
|
criteria = {'artist': name.lower()}
|
||||||
|
|
||||||
with mb_lock:
|
with mb_lock:
|
||||||
@@ -156,16 +152,13 @@ def findRelease(name, limit=1, artist=None):
|
|||||||
if not artist and ':' in name:
|
if not artist and ':' in name:
|
||||||
name, artist = name.rsplit(":", 1)
|
name, artist = name.rsplit(":", 1)
|
||||||
|
|
||||||
chars = set('!?*-')
|
criteria = {'release': name.lower()}
|
||||||
if any((c in chars) for c in name):
|
if artist:
|
||||||
name = '"' + name + '"'
|
criteria['artist'] = artist.lower()
|
||||||
if artist and any((c in chars) for c in artist):
|
|
||||||
artist = '"' + artist + '"'
|
|
||||||
|
|
||||||
with mb_lock:
|
with mb_lock:
|
||||||
try:
|
try:
|
||||||
releaseResults = musicbrainzngs.search_releases(query=name, limit=limit, artist=artist)[
|
releaseResults = musicbrainzngs.search_releases(limit=limit, **criteria)['release-list']
|
||||||
'release-list']
|
|
||||||
except musicbrainzngs.WebServiceError as e: # need to update exceptions
|
except musicbrainzngs.WebServiceError as e: # need to update exceptions
|
||||||
logger.warn('Attempt to query MusicBrainz for "%s" failed: %s' % (name, str(e)))
|
logger.warn('Attempt to query MusicBrainz for "%s" failed: %s' % (name, str(e)))
|
||||||
mb_lock.snooze(5)
|
mb_lock.snooze(5)
|
||||||
@@ -234,10 +227,6 @@ def findSeries(name, limit=1):
|
|||||||
serieslist = []
|
serieslist = []
|
||||||
seriesResults = None
|
seriesResults = None
|
||||||
|
|
||||||
chars = set('!?*-')
|
|
||||||
if any((c in chars) for c in name):
|
|
||||||
name = '"' + name + '"'
|
|
||||||
|
|
||||||
criteria = {'series': name.lower()}
|
criteria = {'series': name.lower()}
|
||||||
|
|
||||||
with mb_lock:
|
with mb_lock:
|
||||||
@@ -759,19 +748,12 @@ def findArtistbyAlbum(name):
|
|||||||
|
|
||||||
def findAlbumID(artist=None, album=None):
|
def findAlbumID(artist=None, album=None):
|
||||||
results = None
|
results = None
|
||||||
chars = set('!?*-')
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if album and artist:
|
if album and artist:
|
||||||
if any((c in chars) for c in album):
|
|
||||||
album = '"' + album + '"'
|
|
||||||
if any((c in chars) for c in artist):
|
|
||||||
artist = '"' + artist + '"'
|
|
||||||
criteria = {'release': album.lower()}
|
criteria = {'release': album.lower()}
|
||||||
criteria['artist'] = artist.lower()
|
criteria['artist'] = artist.lower()
|
||||||
else:
|
else:
|
||||||
if any((c in chars) for c in album):
|
|
||||||
album = '"' + album + '"'
|
|
||||||
criteria = {'release': album.lower()}
|
criteria = {'release': album.lower()}
|
||||||
with mb_lock:
|
with mb_lock:
|
||||||
results = musicbrainzngs.search_release_groups(limit=1, **criteria).get(
|
results = musicbrainzngs.search_release_groups(limit=1, **criteria).get(
|
||||||
|
|||||||
+15
-13
@@ -44,28 +44,30 @@ class Rutracker(object):
|
|||||||
logger.info("Attempting to log in to rutracker...")
|
logger.info("Attempting to log in to rutracker...")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
r = self.session.post(loginpage, data=post_params, timeout=self.timeout)
|
r = self.session.post(loginpage, data=post_params, timeout=self.timeout, allow_redirects=False)
|
||||||
# try again
|
# try again
|
||||||
if 'bb_data' not in r.cookies.keys():
|
if not self.has_bb_data_cookie(r):
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
r = self.session.post(loginpage, data=post_params, timeout=self.timeout)
|
r = self.session.post(loginpage, data=post_params, timeout=self.timeout, allow_redirects=False)
|
||||||
if r.status_code != 200:
|
if self.has_bb_data_cookie(r):
|
||||||
logger.error("rutracker login returned status code %s" % r.status_code)
|
self.loggedin = True
|
||||||
self.loggedin = False
|
logger.info("Successfully logged in to rutracker")
|
||||||
else:
|
else:
|
||||||
if 'bb_data' in r.cookies.keys():
|
logger.error(
|
||||||
self.loggedin = True
|
"Could not login to rutracker, credentials maybe incorrect, site is down or too many attempts. Try again later")
|
||||||
logger.info("Successfully logged in to rutracker")
|
self.loggedin = False
|
||||||
else:
|
|
||||||
logger.error(
|
|
||||||
"Could not login to rutracker, credentials maybe incorrect, site is down or too many attempts. Try again later")
|
|
||||||
self.loggedin = False
|
|
||||||
return self.loggedin
|
return self.loggedin
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Unknown error logging in to rutracker: %s" % e)
|
logger.error("Unknown error logging in to rutracker: %s" % e)
|
||||||
self.loggedin = False
|
self.loggedin = False
|
||||||
return self.loggedin
|
return self.loggedin
|
||||||
|
|
||||||
|
def has_bb_data_cookie(self, response):
|
||||||
|
if 'bb_data' in response.cookies.keys():
|
||||||
|
return True
|
||||||
|
# Rutracker randomly send a 302 redirect code, cookie may be present in response history
|
||||||
|
return next(('bb_data' in r.cookies.keys() for r in response.history), False)
|
||||||
|
|
||||||
def searchurl(self, artist, album, year, format):
|
def searchurl(self, artist, album, year, format):
|
||||||
"""
|
"""
|
||||||
Return the search url
|
Return the search url
|
||||||
|
|||||||
+87
-1
@@ -14,6 +14,7 @@
|
|||||||
# along with Headphones. If not, see <http://www.gnu.org/licenses/>.
|
# along with Headphones. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# NZBGet support added by CurlyMo <curlymoo1@gmail.com> as a part of XBian - XBMC on the Raspberry Pi
|
# NZBGet support added by CurlyMo <curlymoo1@gmail.com> as a part of XBian - XBMC on the Raspberry Pi
|
||||||
|
# t411 support added by a1ex, @likeitneverwentaway on github for maintenance
|
||||||
|
|
||||||
from base64 import b16encode, b32decode
|
from base64 import b16encode, b32decode
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
@@ -24,6 +25,7 @@ import datetime
|
|||||||
import subprocess
|
import subprocess
|
||||||
import unicodedata
|
import unicodedata
|
||||||
import urlparse
|
import urlparse
|
||||||
|
from json import loads
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@@ -813,6 +815,19 @@ def send_to_downloader(data, bestqual, album):
|
|||||||
torrent_name = helpers.replace_illegal_chars(folder_name) + '.torrent'
|
torrent_name = helpers.replace_illegal_chars(folder_name) + '.torrent'
|
||||||
download_path = os.path.join(headphones.CONFIG.TORRENTBLACKHOLE_DIR, torrent_name)
|
download_path = os.path.join(headphones.CONFIG.TORRENTBLACKHOLE_DIR, torrent_name)
|
||||||
|
|
||||||
|
# Blackhole for t411
|
||||||
|
if bestqual[2].lower().startswith("http://api.t411"):
|
||||||
|
if headphones.CONFIG.MAGNET_LINKS == 2:
|
||||||
|
try:
|
||||||
|
url = bestqual[2].split('TOKEN')[0]
|
||||||
|
token = bestqual[2].split('TOKEN')[1]
|
||||||
|
data = request.request_content(url, headers={'Authorization': token})
|
||||||
|
torrent_to_file(download_path, data)
|
||||||
|
logger.info('Successfully converted magnet to torrent file')
|
||||||
|
except Exception as e:
|
||||||
|
logger.error("Error converting magnet link: %s" % str(e))
|
||||||
|
return
|
||||||
|
|
||||||
if bestqual[2].lower().startswith("magnet:"):
|
if bestqual[2].lower().startswith("magnet:"):
|
||||||
if headphones.CONFIG.MAGNET_LINKS == 1:
|
if headphones.CONFIG.MAGNET_LINKS == 1:
|
||||||
try:
|
try:
|
||||||
@@ -1333,7 +1348,7 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None,
|
|||||||
|
|
||||||
if headphones.CONFIG.WAFFLES:
|
if headphones.CONFIG.WAFFLES:
|
||||||
provider = "Waffles.ch"
|
provider = "Waffles.ch"
|
||||||
providerurl = fix_url("https://www.waffles.ch/browse.php")
|
providerurl = fix_url("https://waffles.ch/browse.php")
|
||||||
|
|
||||||
bitrate = None
|
bitrate = None
|
||||||
if headphones.CONFIG.PREFERRED_QUALITY == 3 or losslessOnly:
|
if headphones.CONFIG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||||
@@ -1763,6 +1778,77 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None,
|
|||||||
resultlist.append((title, size, url, provider, 'torrent', match))
|
resultlist.append((title, size, url, provider, 'torrent', match))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception("Unhandled exception in Mininova Parser")
|
logger.exception("Unhandled exception in Mininova Parser")
|
||||||
|
# t411
|
||||||
|
if headphones.CONFIG.TQUATTRECENTONZE:
|
||||||
|
username = headphones.CONFIG.TQUATTRECENTONZE_USER
|
||||||
|
password = headphones.CONFIG.TQUATTRECENTONZE_PASSWORD
|
||||||
|
API_URL = "http://api.t411.ch"
|
||||||
|
AUTH_URL = API_URL + '/auth'
|
||||||
|
DL_URL = API_URL + '/torrents/download/'
|
||||||
|
provider = "t411"
|
||||||
|
t411_term = term.replace(" ", "%20")
|
||||||
|
SEARCH_URL = API_URL + '/torrents/search/' + t411_term + "?limit=15&cid=395&subcat=623"
|
||||||
|
headers_login = {'username': username, 'password': password}
|
||||||
|
|
||||||
|
# Requesting content
|
||||||
|
logger.info('Parsing results from t411 using search term: %s' % term)
|
||||||
|
req = request.request_content(AUTH_URL, method='post', data=headers_login)
|
||||||
|
|
||||||
|
if len(req.split('"')) == 9:
|
||||||
|
token = req.split('"')[7]
|
||||||
|
headers_auth = {'Authorization': token}
|
||||||
|
logger.info('t411 - User %s logged in' % username)
|
||||||
|
else:
|
||||||
|
logger.info('t411 - Login error : %s' % req.split('"')[3])
|
||||||
|
|
||||||
|
# Quality
|
||||||
|
if headphones.CONFIG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||||
|
providerurl = fix_url(SEARCH_URL + "&term[16][]=529&term[16][]=1184")
|
||||||
|
elif headphones.CONFIG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||||
|
providerurl = fix_url(SEARCH_URL + "&term[16][]=685&term[16][]=527&term[16][]=1070&term[16][]=528&term[16][]=1167&term[16][]=1166&term[16][]=530&term[16][]=529&term[16][]=1184&term[16][]=532&term[16][]=533&term[16][]=1085&term[16][]=534&term[16][]=535&term[16][]=1069&term[16][]=537&term[16][]=538")
|
||||||
|
elif headphones.CONFIG.PREFERRED_QUALITY == 0:
|
||||||
|
providerurl = fix_url(SEARCH_URL + "&term[16][]=685&term[16][]=527&term[16][]=1070&term[16][]=528&term[16][]=1167&term[16][]=1166&term[16][]=530&term[16][]=532&term[16][]=533&term[16][]=1085&term[16][]=534&term[16][]=535&term[16][]=1069&term[16][]=537&term[16][]=538")
|
||||||
|
else:
|
||||||
|
providerurl = fix_url(SEARCH_URL)
|
||||||
|
|
||||||
|
# Tracker search
|
||||||
|
req = request.request_content(providerurl, headers=headers_auth)
|
||||||
|
req = loads(req)
|
||||||
|
total = req['total']
|
||||||
|
|
||||||
|
# Process feed
|
||||||
|
if total == '0':
|
||||||
|
logger.info("No results found from t411 for %s" % term)
|
||||||
|
else:
|
||||||
|
logger.info('Found %s results from t411' % total)
|
||||||
|
torrents = req['torrents']
|
||||||
|
for torrent in torrents:
|
||||||
|
try:
|
||||||
|
title = torrent['name']
|
||||||
|
if torrent['seeders'] < minimumseeders:
|
||||||
|
logger.info('Skipping torrent %s : seeders below minimum set' % title)
|
||||||
|
continue
|
||||||
|
id = torrent['id']
|
||||||
|
size = int(torrent['size'])
|
||||||
|
data = request.request_content(DL_URL + id, headers=headers_auth)
|
||||||
|
|
||||||
|
# Blackhole
|
||||||
|
if headphones.CONFIG.TORRENT_DOWNLOADER == 0 and headphones.CONFIG.MAGNET_LINKS == 2:
|
||||||
|
url = DL_URL + id + 'TOKEN' + token
|
||||||
|
resultlist.append((title, size, url, provider, 'torrent', True))
|
||||||
|
|
||||||
|
# Build magnet
|
||||||
|
else:
|
||||||
|
metadata = bdecode(data)
|
||||||
|
hashcontents = bencode(metadata['info'])
|
||||||
|
digest = sha1(hashcontents).hexdigest()
|
||||||
|
trackers = [metadata["announce"]][0]
|
||||||
|
url = 'magnet:?xt=urn:btih:%s&tr=%s' % (digest, trackers)
|
||||||
|
resultlist.append((title, size, url, provider, 'torrent', True))
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logger.error("Error converting magnet link: %s" % str(e))
|
||||||
|
return
|
||||||
|
|
||||||
# attempt to verify that this isn't a substring result
|
# attempt to verify that this isn't a substring result
|
||||||
# when looking for "Foo - Foo" we don't want "Foobar"
|
# when looking for "Foo - Foo" we don't want "Foobar"
|
||||||
|
|||||||
+11
-2
@@ -14,6 +14,7 @@
|
|||||||
# along with Headphones. If not, see <http://www.gnu.org/licenses/>.
|
# along with Headphones. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# NZBGet support added by CurlyMo <curlymoo1@gmail.com> as a part of XBian - XBMC on the Raspberry Pi
|
# NZBGet support added by CurlyMo <curlymoo1@gmail.com> as a part of XBian - XBMC on the Raspberry Pi
|
||||||
|
# t411 support added by a1ex, @likeitneverwentaway on github for maintenance
|
||||||
|
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
import threading
|
import threading
|
||||||
@@ -28,7 +29,7 @@ import urllib2
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from headphones import logger, searcher, db, importer, mb, lastfm, librarysync, helpers, notifiers
|
from headphones import logger, searcher, db, importer, mb, lastfm, librarysync, helpers, notifiers, crier
|
||||||
from headphones.helpers import checked, radio, today, clean_name
|
from headphones.helpers import checked, radio, today, clean_name
|
||||||
from mako.lookup import TemplateLookup
|
from mako.lookup import TemplateLookup
|
||||||
from mako import exceptions
|
from mako import exceptions
|
||||||
@@ -69,6 +70,11 @@ class WebInterface(object):
|
|||||||
artists = myDB.select('SELECT * from artists order by ArtistSortName COLLATE NOCASE')
|
artists = myDB.select('SELECT * from artists order by ArtistSortName COLLATE NOCASE')
|
||||||
return serve_template(templatename="index.html", title="Home", artists=artists)
|
return serve_template(templatename="index.html", title="Home", artists=artists)
|
||||||
|
|
||||||
|
@cherrypy.expose
|
||||||
|
def threads(self):
|
||||||
|
crier.cry()
|
||||||
|
raise cherrypy.HTTPRedirect("home")
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def artistPage(self, ArtistID):
|
def artistPage(self, ArtistID):
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
@@ -1224,6 +1230,9 @@ class WebInterface(object):
|
|||||||
"whatcd_ratio": headphones.CONFIG.WHATCD_RATIO,
|
"whatcd_ratio": headphones.CONFIG.WHATCD_RATIO,
|
||||||
"use_strike": checked(headphones.CONFIG.STRIKE),
|
"use_strike": checked(headphones.CONFIG.STRIKE),
|
||||||
"strike_ratio": headphones.CONFIG.STRIKE_RATIO,
|
"strike_ratio": headphones.CONFIG.STRIKE_RATIO,
|
||||||
|
"use_tquattrecentonze": checked(headphones.CONFIG.TQUATTRECENTONZE),
|
||||||
|
"tquattrecentonze_user": headphones.CONFIG.TQUATTRECENTONZE_USER,
|
||||||
|
"tquattrecentonze_password": headphones.CONFIG.TQUATTRECENTONZE_PASSWORD,
|
||||||
"pref_qual_0": radio(headphones.CONFIG.PREFERRED_QUALITY, 0),
|
"pref_qual_0": radio(headphones.CONFIG.PREFERRED_QUALITY, 0),
|
||||||
"pref_qual_1": radio(headphones.CONFIG.PREFERRED_QUALITY, 1),
|
"pref_qual_1": radio(headphones.CONFIG.PREFERRED_QUALITY, 1),
|
||||||
"pref_qual_2": radio(headphones.CONFIG.PREFERRED_QUALITY, 2),
|
"pref_qual_2": radio(headphones.CONFIG.PREFERRED_QUALITY, 2),
|
||||||
@@ -1420,7 +1429,7 @@ class WebInterface(object):
|
|||||||
"use_newznab", "newznab_enabled", "use_torznab", "torznab_enabled",
|
"use_newznab", "newznab_enabled", "use_torznab", "torznab_enabled",
|
||||||
"use_nzbsorg", "use_omgwtfnzbs", "use_kat", "use_piratebay", "use_oldpiratebay",
|
"use_nzbsorg", "use_omgwtfnzbs", "use_kat", "use_piratebay", "use_oldpiratebay",
|
||||||
"use_mininova", "use_waffles", "use_rutracker",
|
"use_mininova", "use_waffles", "use_rutracker",
|
||||||
"use_whatcd", "use_strike", "preferred_bitrate_allow_lossless", "detect_bitrate",
|
"use_whatcd", "use_strike", "use_tquattrecentonze", "preferred_bitrate_allow_lossless", "detect_bitrate",
|
||||||
"ignore_clean_releases", "freeze_db", "cue_split", "move_files",
|
"ignore_clean_releases", "freeze_db", "cue_split", "move_files",
|
||||||
"rename_files", "correct_metadata", "cleanup_files", "keep_nfo", "add_album_art",
|
"rename_files", "correct_metadata", "cleanup_files", "keep_nfo", "add_album_art",
|
||||||
"embed_album_art", "embed_lyrics",
|
"embed_album_art", "embed_lyrics",
|
||||||
|
|||||||
+16
-37
@@ -1,7 +1,8 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# PROVIDE: headphones
|
# PROVIDE: headphones
|
||||||
# REQUIRE: DAEMON sabnzbd
|
# REQUIRE: DAEMON
|
||||||
|
# BEFORE: LOGIN
|
||||||
# KEYWORD: shutdown
|
# KEYWORD: shutdown
|
||||||
#
|
#
|
||||||
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
|
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
|
||||||
@@ -15,56 +16,34 @@
|
|||||||
# as root.
|
# as root.
|
||||||
# headphones_dir: Directory where Headphones lives.
|
# headphones_dir: Directory where Headphones lives.
|
||||||
# Default: /usr/local/headphones
|
# Default: /usr/local/headphones
|
||||||
# headphones_chdir: Change to this directory before running Headphones.
|
|
||||||
# Default is same as headphones_dir.
|
|
||||||
# headphones_pid: The name of the pidfile to create.
|
# headphones_pid: The name of the pidfile to create.
|
||||||
# Default is headphones.pid in headphones_dir.
|
# Default is headphones.pid in headphones_dir.
|
||||||
PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"
|
|
||||||
|
|
||||||
. /etc/rc.subr
|
. /etc/rc.subr
|
||||||
|
|
||||||
name="headphones"
|
name="headphones"
|
||||||
rcvar=${name}_enable
|
rcvar=${name}_enable
|
||||||
|
|
||||||
load_rc_config ${name}
|
|
||||||
|
|
||||||
: "${headphones_enable:="NO"}"
|
: "${headphones_enable:="NO"}"
|
||||||
: "${headphones_user:="_sabnzbd"}"
|
: "${headphones_user:="_sabnzbd"}"
|
||||||
: "${headphones_dir:="/usr/local/headphones"}"
|
: "${headphones_dir:="/usr/local/headphones"}"
|
||||||
: "${headphones_chdir:="${headphones_dir}"}"
|
: "${headphones_conf:="/usr/local/headphones/config.ini"}"
|
||||||
: "${headphones_pid:="${headphones_dir}/headphones.pid"}"
|
|
||||||
|
|
||||||
status_cmd="${name}_status"
|
command="${headphones_dir}/Headphones.py"
|
||||||
stop_cmd="${name}_stop"
|
command_interpreter="/usr/bin/python"
|
||||||
|
pidfile="/var/run/headphones/headphones.pid"
|
||||||
|
start_precmd="headphones_start_precmd"
|
||||||
|
headphones_flags="--daemon --nolaunch --pidfile $pidfile --config $headphones_conf $headphones_flags"
|
||||||
|
|
||||||
command="/usr/sbin/daemon"
|
headphones_start_precmd() {
|
||||||
command_args="-f -p ${headphones_pid} python ${headphones_dir}/Headphones.py ${headphones_flags} --quiet --nolaunch"
|
if [ $($ID -u) != 0 ]; then
|
||||||
|
err 1 "Must be root."
|
||||||
|
fi
|
||||||
|
|
||||||
# Ensure user is root when running this script.
|
if [ ! -d /var/run/headphones ]; then
|
||||||
if [ "$(id -u)" != "0" ]; then
|
install -do $headphones_user /var/run/headphones
|
||||||
echo "Oops, you should be root before running this!"
|
fi
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
verify_headphones_pid() {
|
|
||||||
# Make sure the pid corresponds to the Headphones process.
|
|
||||||
pid=$(cat "${headphones_pid}" 2>/dev/null)
|
|
||||||
pgrep -F "${headphones_pid}" -q "python ${headphones_dir}/Headphones.py"
|
|
||||||
return $?
|
|
||||||
}
|
|
||||||
|
|
||||||
# Try to stop Headphones cleanly by calling shutdown over http.
|
|
||||||
headphones_stop() {
|
|
||||||
echo "Stopping $name"
|
|
||||||
verify_headphones_pid
|
|
||||||
if [ -n "${pid}" ]; then
|
|
||||||
wait_for_pids "${pid}"
|
|
||||||
echo "Stopped"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
headphones_status() {
|
|
||||||
verify_headphones_pid && echo "$name is running as ${pid}" || echo "$name is not running"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load_rc_config ${name}
|
||||||
run_rc_command "$1"
|
run_rc_command "$1"
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
## PYTHON_BIN= #$DAEMON, the location of the python binary, the default is /usr/bin/python
|
## PYTHON_BIN= #$DAEMON, the location of the python binary, the default is /usr/bin/python
|
||||||
## HP_OPTS= #$EXTRA_DAEMON_OPTS, extra cli option for headphones, i.e. " --config=/home/headphones/config.ini"
|
## HP_OPTS= #$EXTRA_DAEMON_OPTS, extra cli option for headphones, i.e. " --config=/home/headphones/config.ini"
|
||||||
## HP_PORT= #$PORT_OPTS, hardcoded port for the webserver, overrides value in config.ini
|
## HP_PORT= #$PORT_OPTS, hardcoded port for the webserver, overrides value in config.ini
|
||||||
|
## HP_HOST= #$HOST_OPTS, host for the webserver, overrides value in config.ini
|
||||||
##
|
##
|
||||||
## EXAMPLE if want to run as different user
|
## EXAMPLE if want to run as different user
|
||||||
## add HP_USER=username to /etc/default/headphones
|
## add HP_USER=username to /etc/default/headphones
|
||||||
@@ -105,7 +106,12 @@ load_settings() {
|
|||||||
PORT_OPTS=" --port=${HP_PORT} "
|
PORT_OPTS=" --port=${HP_PORT} "
|
||||||
}
|
}
|
||||||
|
|
||||||
DAEMON_OPTS=" Headphones.py --quiet --daemon --nolaunch --pidfile=${PID_FILE} --datadir=${DATA_DIR} ${PORT_OPTS}${EXTRA_DAEMON_OPTS}"
|
# Host config
|
||||||
|
[ -n "$HP_HOST" ] && {
|
||||||
|
HOST_OPTS=" --host=${HP_HOST} "
|
||||||
|
}
|
||||||
|
|
||||||
|
DAEMON_OPTS=" Headphones.py --quiet --daemon --nolaunch --pidfile=${PID_FILE} --datadir=${DATA_DIR} ${PORT_OPTS} ${HOST_OPTS} ${EXTRA_DAEMON_OPTS}"
|
||||||
|
|
||||||
SETTINGS_LOADED=TRUE
|
SETTINGS_LOADED=TRUE
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -99,12 +99,14 @@ DEFAULT_BUFFER_SIZE = -1
|
|||||||
|
|
||||||
|
|
||||||
class FauxSocket(object):
|
class FauxSocket(object):
|
||||||
|
|
||||||
"""Faux socket with the minimal interface required by pypy"""
|
"""Faux socket with the minimal interface required by pypy"""
|
||||||
|
|
||||||
def _reuse(self):
|
def _reuse(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def _drop(self):
|
||||||
|
pass
|
||||||
|
|
||||||
_fileobject_uses_str_type = isinstance(
|
_fileobject_uses_str_type = isinstance(
|
||||||
socket._fileobject(FauxSocket())._rbuf, basestring)
|
socket._fileobject(FauxSocket())._rbuf, basestring)
|
||||||
del FauxSocket # this class is not longer required for anything.
|
del FauxSocket # this class is not longer required for anything.
|
||||||
|
|||||||
Reference in New Issue
Block a user