Merge branch 'master' of uh_wot/deemix into master
This commit is contained in:
commit
1c8fe8fd64
|
@ -1,7 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import binascii
|
import binascii
|
||||||
import hashlib
|
import hashlib
|
||||||
from urllib.request import urlopen
|
|
||||||
|
|
||||||
import blowfish
|
import blowfish
|
||||||
import pyaes
|
import pyaes
|
||||||
|
@ -254,13 +253,10 @@ class Deezer:
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
def stream_track(self, track_id, url, stream):
|
def stream_track(self, track_id, url, stream):
|
||||||
response = urlopen(url)
|
request = requests.get(url, stream=True)
|
||||||
cipher = blowfish.Cipher(str.encode(self._get_blowfish_key(str(track_id))))
|
cipher = blowfish.Cipher(str.encode(self._get_blowfish_key(str(track_id))))
|
||||||
i = 0
|
i = 0
|
||||||
while True:
|
for chunk in request.iter_content(2048):
|
||||||
chunk = response.read(2048)
|
|
||||||
if not chunk:
|
|
||||||
break
|
|
||||||
if (i % 3) == 0 and len(chunk) == 2048:
|
if (i % 3) == 0 and len(chunk) == 2048:
|
||||||
chunk = b"".join(cipher.decrypt_cbc(chunk, b"\x00\x01\x02\x03\x04\x05\x06\x07"))
|
chunk = b"".join(cipher.decrypt_cbc(chunk, b"\x00\x01\x02\x03\x04\x05\x06\x07"))
|
||||||
stream.write(chunk)
|
stream.write(chunk)
|
||||||
|
|
|
@ -4,8 +4,8 @@ from deemix.utils.taggers import tagID3, tagFLAC
|
||||||
from deemix.utils.pathtemplates import generateFilename, generateFilepath, settingsRegexAlbum, settingsRegexArtist
|
from deemix.utils.pathtemplates import generateFilename, generateFilepath, settingsRegexAlbum, settingsRegexArtist
|
||||||
import os.path
|
import os.path
|
||||||
from os import makedirs
|
from os import makedirs
|
||||||
from urllib.request import urlopen
|
from requests import get
|
||||||
from urllib.error import HTTPError
|
from requests.exceptions import HTTPError
|
||||||
from tempfile import gettempdir
|
from tempfile import gettempdir
|
||||||
|
|
||||||
dz = Deezer()
|
dz = Deezer()
|
||||||
|
@ -23,8 +23,8 @@ extensions = {
|
||||||
13: '.mp4'
|
13: '.mp4'
|
||||||
}
|
}
|
||||||
|
|
||||||
def getPreferredBitrare(filesize, bitrate):
|
def getPreferredBitrate(filesize, bitrate):
|
||||||
bitrateFound = False;
|
bitrateFound = False
|
||||||
selectedFormat = 0
|
selectedFormat = 0
|
||||||
selectedFilesize = 0
|
selectedFilesize = 0
|
||||||
if int(bitrate) == 9:
|
if int(bitrate) == 9:
|
||||||
|
@ -253,7 +253,7 @@ def downloadTrackObj(trackAPI, settings, overwriteBitrate=False, extraTrack=None
|
||||||
|
|
||||||
# Get the selected bitrate
|
# Get the selected bitrate
|
||||||
bitrate = overwriteBitrate if overwriteBitrate else settings['maxBitrate']
|
bitrate = overwriteBitrate if overwriteBitrate else settings['maxBitrate']
|
||||||
(format, filesize) = getPreferredBitrare(track['filesize'], bitrate)
|
(format, filesize) = getPreferredBitrate(track['filesize'], bitrate)
|
||||||
track['selectedFormat'] = format
|
track['selectedFormat'] = format
|
||||||
track['selectedFilesize'] = filesize
|
track['selectedFilesize'] = filesize
|
||||||
track['album']['bitrate'] = format
|
track['album']['bitrate'] = format
|
||||||
|
@ -268,7 +268,7 @@ def downloadTrackObj(trackAPI, settings, overwriteBitrate=False, extraTrack=None
|
||||||
if not os.path.isfile(track['album']['picPath']):
|
if not os.path.isfile(track['album']['picPath']):
|
||||||
with open(track['album']['picPath'], 'wb') as f:
|
with open(track['album']['picPath'], 'wb') as f:
|
||||||
try:
|
try:
|
||||||
f.write(urlopen(track['album']['picUrl']).read())
|
f.write(get(track['album']['picUrl']).content)
|
||||||
except HTTPError:
|
except HTTPError:
|
||||||
track['album']['picPath'] = None
|
track['album']['picPath'] = None
|
||||||
|
|
||||||
|
|
|
@ -2,3 +2,4 @@ pyaes
|
||||||
blowfish
|
blowfish
|
||||||
mutagen
|
mutagen
|
||||||
click
|
click
|
||||||
|
requests
|
||||||
|
|
Loading…
Reference in New Issue