Skip to content

Commit

Permalink
Merge pull request #1106 from exislow/gui-playlists
Browse files Browse the repository at this point in the history
[GUI] Show user's playlists and allow to download them.
  • Loading branch information
yaronzz authored Oct 31, 2023
2 parents 62d83b5 + df7c444 commit a8da5c0
Show file tree
Hide file tree
Showing 10 changed files with 256 additions and 161 deletions.
3 changes: 2 additions & 1 deletion TIDALDL-PY/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ lyricsgenius==3.0.1
pydub==0.25.1
PyQt5==5.15.7
qt-material==2.12
lxml==4.7.1
lxml==4.7.1
tidalapi==0.7.3
35 changes: 18 additions & 17 deletions TIDALDL-PY/tidal_dl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,28 @@
@Author : Yaronzz
@Version : 3.0
@Contact : [email protected]
@Desc :
@Desc :
'''
import sys
import getopt

from tidal_dl.events import *
from tidal_dl.settings import *
from tidal_dl.gui import startGui
from events import *
from settings import *
from gui import startGui


def mainCommand():
try:
opts, args = getopt.getopt(sys.argv[1:],
"hvgl:o:q:r:",
opts, args = getopt.getopt(sys.argv[1:],
"hvgl:o:q:r:",
["help", "version", "gui", "link=", "output=", "quality", "resolution"])
except getopt.GetoptError as errmsg:
Printf.err(vars(errmsg)['msg'] + ". Use 'tidal-dl -h' for useage.")
Printf.err(vars(errmsg)['msg'] + ". Use 'tidal-dl -h' for usage.")
return

link = None
showGui = False

for opt, val in opts:
if opt in ('-h', '--help'):
Printf.usage()
Expand All @@ -52,11 +53,11 @@ def mainCommand():
SETTINGS.videoQuality = SETTINGS.getVideoQuality(val)
SETTINGS.save()
continue

if not aigpy.path.mkdirs(SETTINGS.downloadPath):
Printf.err(LANG.select.MSG_PATH_ERR + SETTINGS.downloadPath)
return

if showGui:
startGui()
return
Expand All @@ -71,22 +72,22 @@ def main():
SETTINGS.read(getProfilePath())
TOKEN.read(getTokenPath())
TIDAL_API.apiKey = apiKey.getItem(SETTINGS.apiKeyIndex)

if len(sys.argv) > 1:
mainCommand()
return

Printf.logo()
Printf.settings()

if not apiKey.isItemValid(SETTINGS.apiKeyIndex):
changeApiKey()
loginByWeb()
elif not loginByConfig():
loginByWeb()

Printf.checkVersion()

while True:
Printf.choices()
choice = Printf.enter(LANG.select.PRINT_ENTER_CHOICE)
Expand Down Expand Up @@ -115,10 +116,10 @@ def main():
def test():
SETTINGS.read(getProfilePath())
TOKEN.read(getTokenPath())

if not loginByConfig():
loginByWeb()

SETTINGS.audioQuality = AudioQuality.Master
SETTINGS.videoFileFormat = VideoQuality.P240
SETTINGS.checkExist = False
Expand Down Expand Up @@ -149,7 +150,7 @@ def test():
# playlist 98235845-13e8-43b4-94e2-d9f8e603cee7
# start('98235845-13e8-43b4-94e2-d9f8e603cee7')
# video 155608351 188932980 https://tidal.com/browse/track/55130637
# start("155608351")https://tidal.com/browse/track/199683732
# start("155608351")https://tidal.com/browse/track/199683732


if __name__ == '__main__':
Expand Down
25 changes: 12 additions & 13 deletions TIDALDL-PY/tidal_dl/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@
@Author : Yaronzz
@Version : 1.0
@Contact : [email protected]
@Desc :
@Desc :
'''
import aigpy
import logging

from tidal_dl.paths import *
from tidal_dl.printf import *
from tidal_dl.decryption import *
from tidal_dl.tidal import *

from concurrent.futures import ThreadPoolExecutor

from decryption import *
from printf import *
from tidal import *


def __isSkip__(finalpath, url):
if not SETTINGS.checkExist:
return False
Expand Down Expand Up @@ -114,7 +112,7 @@ def downloadVideo(video: Video, album: Album = None, playlist: Playlist = None):
try:
stream = TIDAL_API.getVideoStreamUrl(video.id, SETTINGS.videoQuality)
path = getVideoPath(video, album, playlist)

Printf.video(video, stream)
logging.info("[DL Video] name=" + aigpy.path.getFileName(path) + "\nurl=" + stream.m3u8Url)

Expand Down Expand Up @@ -164,7 +162,7 @@ def downloadTrack(track: Track, album=None, playlist=None, userProgress=None, pa
tool.setPartSize(partSize)
check, err = tool.start(SETTINGS.showProgress and not SETTINGS.multiThread)
if not check:
Printf.err(f"DL Track[{track.title}] failed.{str(err)}")
Printf.err(f"DL Track '{track.title}' failed: {str(err)}")
return False, str(err)

# encrypted -> decrypt and remove encrypted file
Expand All @@ -187,19 +185,20 @@ def downloadTrack(track: Track, album=None, playlist=None, userProgress=None, pa

__setMetaData__(track, album, path, contributors, lyrics)
Printf.success(track.title)

return True, ''
except Exception as e:
Printf.err(f"DL Track[{track.title}] failed.{str(e)}")
Printf.err(f"DL Track '{track.title}' failed: {str(e)}")
return False, str(e)


def downloadTracks(tracks, album: Album = None, playlist : Playlist=None):
def downloadTracks(tracks, album: Album = None, playlist: Playlist = None):
def __getAlbum__(item: Track):
album = TIDAL_API.getAlbum(item.album.id)
if SETTINGS.saveCovers and not SETTINGS.usePlaylistFolder:
downloadCover(album)
return album

if not SETTINGS.multiThread:
for index, item in enumerate(tracks):
itemAlbum = album
Expand Down
11 changes: 2 additions & 9 deletions TIDALDL-PY/tidal_dl/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,10 @@
@Author : Yaronzz
@Version : 1.0
@Contact : [email protected]
@Desc :
@Desc :
"""

import aigpy
import time

from tidal_dl.model import *
from tidal_dl.enums import *
from tidal_dl.tidal import *
from tidal_dl.printf import *
from tidal_dl.download import *
from download import *

'''
=================================
Expand Down
Loading

0 comments on commit a8da5c0

Please sign in to comment.