diff --git a/README.md b/README.md index 78db746..9b6ad09 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ # How to use -Install wxpython (check if there are builded packages for your distribution, if not then just run `pip install wxpython` and it should build it for your system)
-Install the rest of the dependencies using `pip install -r requirements.txt`
-Run `python -m deemix` to run the app +Install the dependencies using `pip install -r requirements.txt`
+Run `python -m deemix --help` to see how to use the app # TODO -Find all dependencies and add them to requirements.txt
Making the download work in multi-threading
-Add the settings in the GUI
-Finish porting all features +Finish porting all features
+Make the GUI after all is implemented diff --git a/deemix/__main__.py b/deemix/__main__.py index 13ef5eb..4b779b4 100644 --- a/deemix/__main__.py +++ b/deemix/__main__.py @@ -1,9 +1,28 @@ #!/usr/bin/env python3 -import wx +import click +from deemix.utils.misc import getIDFromLink, getTypeFromLink, getBitrateInt +from deemix.app.downloader import download_track, download_album, download_playlist +from deemix.app.settings import initSettings -from deemix.ui.MainFrame import MainFrame +@click.command() +@click.option('-b', '--bitrate', default=None, help='Overwrites the default bitrate selected') +@click.argument('url') +def download(bitrate, url): + settings = initSettings() + forcedBitrate = getBitrateInt(bitrate) + type = getTypeFromLink(url) + id = getIDFromLink(url, type) + if type == None or id == None: + click.echo("URL not recognized") + if type == "track": + download_track(id, settings, forcedBitrate) + elif type == "album": + download_album(id, settings, forcedBitrate) + elif type == "playlist": + download_playlist(id, settings, forcedBitrate) + else: + click.echo("URL not supported yet") + click.echo("All done!") if __name__ == '__main__': - app = wx.App() - frame = MainFrame() - app.MainLoop() + download() diff --git a/deemix/app/default.json b/deemix/app/default.json index 93fe44f..3518b46 100644 --- a/deemix/app/default.json +++ b/deemix/app/default.json @@ -3,8 +3,11 @@ "tracknameTemplate": "%artist% - %title%", "albumTracknameTemplate": "%number% - %title%", "playlistTracknameTemplate": "%position% - %artist% - %title%", + "createPlaylistFolder": true, "playlistNameTemplate": "%name%", - "artistNameTemplate": "", + "createArtistFolder": false, + "artistNameTemplate": "%name%", + "createAlbumFolder": true, "albumNameTemplate": "%artist% - %album%", "createCDFolder": true, "createStructurePlaylist": false, @@ -23,8 +26,10 @@ "syncedLyrics": false, "embeddedArtworkSize": 800, "localArtworkSize": 1000, - "coverImageTemplate": "", - "artistImageTemplate": "", + "saveArtwork": false, + "coverImageTemplate": "cover", + "saveArtworkArtist": false, + "artistImageTemplate": "folder", "multitagSeparator": "default", "dateFormat": "YMD", "savePlaylistAsCompilation": false, diff --git a/deemix/utils/misc.py b/deemix/utils/misc.py index bad7bf6..11340e1 100644 --- a/deemix/utils/misc.py +++ b/deemix/utils/misc.py @@ -1,6 +1,17 @@ #!/usr/bin/env python3 import re +def getBitrateInt(txt): + txt = str(txt) + if txt in ['flac', 'lossless', '9']: + return 9 + elif txt in ['mp3', '320', '3']: + return 3 + elif txt in ['128']: + return 1 + else: + return None + def getIDFromLink(link, type): if '?' in link: link = link[:link.find('?')] diff --git a/requirements.txt b/requirements.txt index 88e3c6a..39ed6e3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ pyaes blowfish mutagen +click