Fixed support with local uploaded tracks

This commit is contained in:
RemixDev 2020-07-02 16:49:17 +02:00
parent 565b205262
commit e51576ab2f
4 changed files with 191 additions and 165 deletions

View File

@ -1,3 +1,3 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
__version__ = "1.1.2" __version__ = "1.1.3"

View File

@ -26,6 +26,7 @@ if not os.path.isdir(TEMPDIR):
extensions = { extensions = {
9: '.flac', 9: '.flac',
0: '.mp3',
3: '.mp3', 3: '.mp3',
1: '.mp3', 1: '.mp3',
8: '.mp3', 8: '.mp3',
@ -127,6 +128,8 @@ def formatDate(date, template):
def getPreferredBitrate(dz, track, bitrate, fallback=True): def getPreferredBitrate(dz, track, bitrate, fallback=True):
if 'localTrack' in track:
return 0
formatsnon360 = [9, 3, 1] # flac, mp3_320, mp3_128 formatsnon360 = [9, 3, 1] # flac, mp3_320, mp3_128
formats360 = [15, 14, 13] # 360_hq, 360_mq, 360_lq formats360 = [15, 14, 13] # 360_hq, 360_mq, 360_lq
if not fallback: if not fallback:
@ -187,18 +190,40 @@ def getTrackData(dz, trackAPI_gw, settings, trackAPI=None, albumAPI_gw=None, alb
track['mainArtist'] = {} track['mainArtist'] = {}
track['mainArtist']['id'] = 0 track['mainArtist']['id'] = 0
track['mainArtist']['name'] = trackAPI_gw['ART_NAME'] track['mainArtist']['name'] = trackAPI_gw['ART_NAME']
track['mainArtist']['pic'] = ""
track['artists'] = [trackAPI_gw['ART_NAME']] track['artists'] = [trackAPI_gw['ART_NAME']]
track['aritst'] = { track['artist'] = {
'Main': [trackAPI_gw['ART_NAME']] 'Main': [trackAPI_gw['ART_NAME']]
} }
track['date'] = { track['date'] = {
'day': 0, 'day': "XXXX",
'month': 0, 'month': "00",
'year': 0 'year': "00"
} }
if 'POSITION' in trackAPI_gw: track['position'] = trackAPI_gw['POSITION']
track['localTrack'] = True track['localTrack'] = True
return track # Missing tags
track['ISRC'] = ""
track['album']['artist'] = track['artist']
track['album']['artists'] = track['artists']
track['album']['barcode'] = "Unknown"
track['album']['date'] = track['date']
track['album']['discTotal'] = "0"
track['album']['explicit'] = False
track['album']['genre'] = []
track['album']['label'] = "Unknown"
track['album']['mainArtist'] = track['mainArtist']
track['album']['recordType'] = "Album"
track['album']['trackTotal'] = "0"
track['bpm'] = 0
track['contributors'] = {}
track['copyright'] = ""
track['discNumber'] = "0"
track['explicit'] = False
track['lyrics'] = {}
track['replayGain'] = ""
track['trackNumber'] = "0"
else:
if 'DISK_NUMBER' in trackAPI_gw: if 'DISK_NUMBER' in trackAPI_gw:
track['discNumber'] = trackAPI_gw['DISK_NUMBER'] track['discNumber'] = trackAPI_gw['DISK_NUMBER']
if 'EXPLICIT_LYRICS' in trackAPI_gw: if 'EXPLICIT_LYRICS' in trackAPI_gw:
@ -825,7 +850,7 @@ def downloadTrackObj(dz, trackAPI, settings, bitrate, queueItem, extraTrack=None
else: else:
logger.info(f"[{track['mainArtist']['name']} - {track['title']}] Skipping track as it's already downloaded") logger.info(f"[{track['mainArtist']['name']} - {track['title']}] Skipping track as it's already downloaded")
trackCompletePercentage(trackAPI, queueItem, interface) trackCompletePercentage(trackAPI, queueItem, interface)
if not trackAlreadyDownloaded or settings['overwriteFile'] in ['t', 'y']: if (not trackAlreadyDownloaded or settings['overwriteFile'] in ['t', 'y']) and not 'localTrack' in track:
logger.info(f"[{track['mainArtist']['name']} - {track['title']}] Applying tags to the track") logger.info(f"[{track['mainArtist']['name']} - {track['title']}] Applying tags to the track")
if track['selectedFormat'] in [3, 1, 8]: if track['selectedFormat'] in [3, 1, 8]:
tagID3(writepath, track, settings['tags']) tagID3(writepath, track, settings['tags'])

View File

@ -9,7 +9,8 @@ bitrateLabels = {
9: "FLAC", 9: "FLAC",
3: "320", 3: "320",
1: "128", 1: "128",
8: "128" 8: "128",
0: "MP3"
} }

View File

@ -7,7 +7,7 @@ README = (HERE / "README.md").read_text()
setup( setup(
name="deemix", name="deemix",
version="1.1.2", version="1.1.3",
description="A barebone deezer downloader library", description="A barebone deezer downloader library",
long_description=README, long_description=README,
long_description_content_type="text/markdown", long_description_content_type="text/markdown",