mirror of
https://github.com/rembo10/headphones.git
synced 2026-07-21 16:34:01 +01:00
Fix travis errors
This commit is contained in:
+841
-957
File diff suppressed because it is too large
Load Diff
@@ -26,7 +26,6 @@ import binascii
|
|||||||
from beets.mediafile import MediaFile
|
from beets.mediafile import MediaFile
|
||||||
from headphones import logger, request, helpers
|
from headphones import logger, request, helpers
|
||||||
import headphones
|
import headphones
|
||||||
from twisted.conch.insults import helper
|
|
||||||
|
|
||||||
# Public constants
|
# Public constants
|
||||||
PROVIDER_NAME = 'Deezer'
|
PROVIDER_NAME = 'Deezer'
|
||||||
@@ -53,6 +52,7 @@ __cookies = None
|
|||||||
__tracks_cache = {}
|
__tracks_cache = {}
|
||||||
__albums_cache = {}
|
__albums_cache = {}
|
||||||
|
|
||||||
|
|
||||||
def __getApiToken():
|
def __getApiToken():
|
||||||
global __cookies
|
global __cookies
|
||||||
response = request.request_response(url="http://www.deezer.com/", headers=__HTTP_HEADERS)
|
response = request.request_response(url="http://www.deezer.com/", headers=__HTTP_HEADERS)
|
||||||
@@ -68,6 +68,7 @@ def __getApiToken():
|
|||||||
if not token:
|
if not token:
|
||||||
logger.error(u"Deezloader: Unable to get api token")
|
logger.error(u"Deezloader: Unable to get api token")
|
||||||
|
|
||||||
|
|
||||||
def getAlbumByLink(album_link):
|
def getAlbumByLink(album_link):
|
||||||
"""Returns deezer album infos using album link url
|
"""Returns deezer album infos using album link url
|
||||||
|
|
||||||
@@ -77,6 +78,7 @@ def getAlbumByLink(album_link):
|
|||||||
if matches:
|
if matches:
|
||||||
return getAlbum(matches.group(1))
|
return getAlbum(matches.group(1))
|
||||||
|
|
||||||
|
|
||||||
def getAlbum(album_id):
|
def getAlbum(album_id):
|
||||||
"""Returns deezer album infos
|
"""Returns deezer album infos
|
||||||
|
|
||||||
@@ -97,6 +99,7 @@ def getAlbum(album_id):
|
|||||||
logger.debug("Deezloader: Can't load album infos")
|
logger.debug("Deezloader: Can't load album infos")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def searchAlbums(search_term):
|
def searchAlbums(search_term):
|
||||||
"""Search for deezer albums using search term
|
"""Search for deezer albums using search term
|
||||||
|
|
||||||
@@ -121,6 +124,7 @@ def searchAlbums(search_term):
|
|||||||
|
|
||||||
return albums
|
return albums
|
||||||
|
|
||||||
|
|
||||||
def __matchAlbums(albums, artist_name, album_title, album_length):
|
def __matchAlbums(albums, artist_name, album_title, album_length):
|
||||||
resultlist = []
|
resultlist = []
|
||||||
|
|
||||||
@@ -170,6 +174,7 @@ def __matchAlbums(albums, artist_name, album_title, album_length):
|
|||||||
|
|
||||||
return resultlist
|
return resultlist
|
||||||
|
|
||||||
|
|
||||||
def searchAlbum(artist_name, album_title, user_search_term=None, album_length=None):
|
def searchAlbum(artist_name, album_title, user_search_term=None, album_length=None):
|
||||||
"""Search for deezer specific album.
|
"""Search for deezer specific album.
|
||||||
This will iterate over deezer albums and try to find best matches
|
This will iterate over deezer albums and try to find best matches
|
||||||
@@ -201,6 +206,7 @@ def searchAlbum(artist_name, album_title, user_search_term=None, album_length=No
|
|||||||
|
|
||||||
return resultlist
|
return resultlist
|
||||||
|
|
||||||
|
|
||||||
def getTrack(sng_id, try_reload_api=True):
|
def getTrack(sng_id, try_reload_api=True):
|
||||||
"""Returns deezer track infos
|
"""Returns deezer track infos
|
||||||
|
|
||||||
@@ -265,6 +271,7 @@ def getTrack(sng_id, try_reload_api=True):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(u"An unknown error occurred in the Deezer parser: %s" % e)
|
logger.error(u"An unknown error occurred in the Deezer parser: %s" % e)
|
||||||
|
|
||||||
|
|
||||||
def __getDownloadUrl(md5Origin, sng_id, sng_format, mediaVersion):
|
def __getDownloadUrl(md5Origin, sng_id, sng_format, mediaVersion):
|
||||||
urlPart = md5Origin.encode('utf-8') + b'\xa4' + str(sng_format) + b'\xa4' + str(sng_id) + b'\xa4' + str(mediaVersion)
|
urlPart = md5Origin.encode('utf-8') + b'\xa4' + str(sng_format) + b'\xa4' + str(sng_id) + b'\xa4' + str(mediaVersion)
|
||||||
md5val = md5(urlPart).hexdigest()
|
md5val = md5(urlPart).hexdigest()
|
||||||
@@ -273,6 +280,7 @@ def __getDownloadUrl(md5Origin, sng_id, sng_format, mediaVersion):
|
|||||||
ciphertext = cipher.encrypt(__pad(urlPart, AES.block_size))
|
ciphertext = cipher.encrypt(__pad(urlPart, AES.block_size))
|
||||||
return "http://e-cdn-proxy-" + md5Origin[:1] + ".deezer.com/mobile/1/" + binascii.hexlify(ciphertext).lower()
|
return "http://e-cdn-proxy-" + md5Origin[:1] + ".deezer.com/mobile/1/" + binascii.hexlify(ciphertext).lower()
|
||||||
|
|
||||||
|
|
||||||
def __pad(raw, block_size):
|
def __pad(raw, block_size):
|
||||||
if (len(raw) % block_size == 0):
|
if (len(raw) % block_size == 0):
|
||||||
return raw
|
return raw
|
||||||
@@ -281,6 +289,7 @@ def __pad(raw, block_size):
|
|||||||
data = raw + padding_required * padChar
|
data = raw + padding_required * padChar
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
def __tagTrack(path, track):
|
def __tagTrack(path, track):
|
||||||
try:
|
try:
|
||||||
album = getAlbum(track['ALB_ID'])
|
album = getAlbum(track['ALB_ID'])
|
||||||
@@ -303,6 +312,7 @@ def __tagTrack(path, track):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(u'Unable to tag deezer track "%s": %s' % (path, e))
|
logger.error(u'Unable to tag deezer track "%s": %s' % (path, e))
|
||||||
|
|
||||||
|
|
||||||
def decryptTracks(paths):
|
def decryptTracks(paths):
|
||||||
"""Decrypt downloaded deezer tracks.
|
"""Decrypt downloaded deezer tracks.
|
||||||
|
|
||||||
@@ -364,6 +374,7 @@ def decryptTracks(paths):
|
|||||||
|
|
||||||
return decrypted_tracks
|
return decrypted_tracks
|
||||||
|
|
||||||
|
|
||||||
def __decryptDownload(source, sng_id, dest):
|
def __decryptDownload(source, sng_id, dest):
|
||||||
interval_chunk = 3
|
interval_chunk = 3
|
||||||
chunk_size = 2048
|
chunk_size = 2048
|
||||||
@@ -391,6 +402,7 @@ def __decryptDownload(source, sng_id, dest):
|
|||||||
f.close()
|
f.close()
|
||||||
fout.close()
|
fout.close()
|
||||||
|
|
||||||
|
|
||||||
def __getBlowFishKey(encryptionKey):
|
def __getBlowFishKey(encryptionKey):
|
||||||
if encryptionKey < 1:
|
if encryptionKey < 1:
|
||||||
encryptionKey *= -1
|
encryptionKey *= -1
|
||||||
@@ -402,6 +414,7 @@ def __getBlowFishKey(encryptionKey):
|
|||||||
|
|
||||||
return __xorHex(parts)
|
return __xorHex(parts)
|
||||||
|
|
||||||
|
|
||||||
def __xorHex(parts):
|
def __xorHex(parts):
|
||||||
data = ""
|
data = ""
|
||||||
for i in range(0, 16):
|
for i in range(0, 16):
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ class HelpersTest(TestCase):
|
|||||||
u'Symphonęy Nº9': 'Symphoney No.9',
|
u'Symphonęy Nº9': 'Symphoney No.9',
|
||||||
u'ÆæßðÞIJij': u'AeaessdThIJıj',
|
u'ÆæßðÞIJij': u'AeaessdThIJıj',
|
||||||
u'Obsessió (Cerebral Apoplexy remix)': 'obsessio cerebral '
|
u'Obsessió (Cerebral Apoplexy remix)': 'obsessio cerebral '
|
||||||
'apoplexy remix',
|
'apoplexy remix',
|
||||||
u'Doktór Hałabała i siedmiu zbojów': 'doktor halabala i siedmiu '
|
u'Doktór Hałabała i siedmiu zbojów': 'doktor halabala i siedmiu '
|
||||||
'zbojow',
|
'zbojow',
|
||||||
u'Arbetets Söner och Döttrar': 'arbetets soner och dottrar',
|
u'Arbetets Söner och Döttrar': 'arbetets soner och dottrar',
|
||||||
u'Björk Guðmundsdóttir': 'bjork gudmundsdottir',
|
u'Björk Guðmundsdóttir': 'bjork gudmundsdottir',
|
||||||
u'L\'Arc~en~Ciel': 'larc en ciel',
|
u'L\'Arc~en~Ciel': 'larc en ciel',
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ def verify(albumid, albumpath, Kind=None, forced=False, keep_original_folder=Fal
|
|||||||
" isn't complete yet (duration mismatch). Will try again on the next run")
|
" isn't complete yet (duration mismatch). Will try again on the next run")
|
||||||
return
|
return
|
||||||
|
|
||||||
downloaded_track_list = list(set(downloaded_track_list)) # Remove duplicates
|
downloaded_track_list = list(set(downloaded_track_list)) # Remove duplicates
|
||||||
|
|
||||||
# test #1: metadata - usually works
|
# test #1: metadata - usually works
|
||||||
logger.debug('Verifying metadata...')
|
logger.debug('Verifying metadata...')
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ redobj = None
|
|||||||
# Persistent Aria2 RPC object
|
# Persistent Aria2 RPC object
|
||||||
__aria2rpc_obj = None
|
__aria2rpc_obj = None
|
||||||
|
|
||||||
|
|
||||||
def getAria2RPC():
|
def getAria2RPC():
|
||||||
global __aria2rpc_obj
|
global __aria2rpc_obj
|
||||||
if not __aria2rpc_obj:
|
if not __aria2rpc_obj:
|
||||||
@@ -67,10 +68,12 @@ def getAria2RPC():
|
|||||||
)
|
)
|
||||||
return __aria2rpc_obj
|
return __aria2rpc_obj
|
||||||
|
|
||||||
|
|
||||||
def reconfigure():
|
def reconfigure():
|
||||||
global __aria2rpc_obj
|
global __aria2rpc_obj
|
||||||
__aria2rpc_obj = None
|
__aria2rpc_obj = None
|
||||||
|
|
||||||
|
|
||||||
def fix_url(s, charset="utf-8"):
|
def fix_url(s, charset="utf-8"):
|
||||||
"""
|
"""
|
||||||
Fix the URL so it is proper formatted and encoded.
|
Fix the URL so it is proper formatted and encoded.
|
||||||
@@ -1274,6 +1277,7 @@ def verifyresult(title, artistterm, term, lossless):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def searchDdl(album, new=False, losslessOnly=False, albumlength=None,
|
def searchDdl(album, new=False, losslessOnly=False, albumlength=None,
|
||||||
choose_specific_download=False):
|
choose_specific_download=False):
|
||||||
reldate = album['ReleaseDate']
|
reldate = album['ReleaseDate']
|
||||||
|
|||||||
Reference in New Issue
Block a user