From 3e369babc485d32b4a7d22d2c6d663e8be582dc5 Mon Sep 17 00:00:00 2001 From: CosmicSage Date: Sun, 12 Feb 2023 21:13:54 +0530 Subject: [PATCH 1/6] understanding editable mode setup.py pip install for development && making first change to project --- scdl/scdl.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scdl/scdl.py b/scdl/scdl.py index 8eac798e..0b4b7cb8 100755 --- a/scdl/scdl.py +++ b/scdl/scdl.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # -*- encoding: utf-8 -*- - +#print("hard fucliong:") +#exit() """scdl allows you to download music from Soundcloud Usage: @@ -122,6 +123,7 @@ def handle_exception(exc_type, exc_value, exc_traceback): sys.excepthook = handle_exception def main(): + print("hard fucking") """ Main function, parses the URL from command line arguments """ @@ -956,4 +958,6 @@ def is_ffmpeg_available(): return shutil.which("ffmpeg") is not None if __name__ == "__main__": +# print("hard fucking") +# exit() main() From 99cca17b602d9bf8b8873c410322de50c3649588 Mon Sep 17 00:00:00 2001 From: CosmicSage Date: Tue, 14 Feb 2023 21:55:04 +0530 Subject: [PATCH 2/6] init listening history --- scdl/scdl.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scdl/scdl.py b/scdl/scdl.py index 0b4b7cb8..16ec3b6e 100755 --- a/scdl/scdl.py +++ b/scdl/scdl.py @@ -8,7 +8,7 @@ scdl (-l | me) [-a | -f | -C | -t | -p | -r][-c | --force-metadata] [-n ][-o ][--hidewarnings][--debug | --error][--path ] [--addtofile][--addtimestamp][--onlymp3][--hide-progress][--min-size ] - [--max-size ][--remove][--no-album-tag][--no-playlist-folder] + [--max-size ][--remove][--no-album-tag][--no-playlist-folder][--history] [--download-archive ][--sync ][--extract-artist][--flac][--original-art] [--original-name][--no-original][--only-original][--name-format ] [--strict-playlist][--playlist-name-format ][--client-id ] @@ -39,6 +39,8 @@ --debug Set log level to DEBUG --download-archive [file] Keep track of track IDs in an archive file, and skip already-downloaded files + + --history Download Listening History --error Set log level to ERROR --extract-artist Set artist tag from title instead of username --hide-progress Hide the wget progress bar @@ -123,7 +125,6 @@ def handle_exception(exc_type, exc_value, exc_traceback): sys.excepthook = handle_exception def main(): - print("hard fucking") """ Main function, parses the URL from command line arguments """ @@ -136,6 +137,12 @@ def main(): # Parse arguments arguments = docopt(__doc__, version=__version__) + + if arguments["--history"]: + print("asdhgfosaidnaiabngoland") + print(arguments["-n"], arguments["-o"]) + exit(123) + if arguments["--debug"]: logger.level = logging.DEBUG elif arguments["--error"]: From 96f37f577a1488306c3b0ec2fb6f148d1c09a33b Mon Sep 17 00:00:00 2001 From: CosmicSage Date: Fri, 17 Feb 2023 12:35:39 +0530 Subject: [PATCH 3/6] implementation of Listening History Download in scdl (Basic) --- scdl/scdl.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/scdl/scdl.py b/scdl/scdl.py index 16ec3b6e..5eef61a8 100755 --- a/scdl/scdl.py +++ b/scdl/scdl.py @@ -1,7 +1,5 @@ #!/usr/bin/env python3 # -*- encoding: utf-8 -*- -#print("hard fucliong:") -#exit() """scdl allows you to download music from Soundcloud Usage: @@ -138,10 +136,6 @@ def main(): arguments = docopt(__doc__, version=__version__) - if arguments["--history"]: - print("asdhgfosaidnaiabngoland") - print(arguments["-n"], arguments["-o"]) - exit(123) if arguments["--debug"]: logger.level = logging.DEBUG @@ -338,6 +332,7 @@ def download_url(client: SoundCloud, **kwargs): if kwargs.get("strict_playlist"): sys.exit(1) logger.info(f"Downloaded all likes of user {user.username}!") + elif kwargs.get("C"): logger.info(f"Retrieving all commented tracks of user {user.username}...") resources = client.get_user_comments(user.id, limit=1000) @@ -345,6 +340,25 @@ def download_url(client: SoundCloud, **kwargs): logger.info(f"comment n°{i} of {user.comments_count}") download_track(client, client.get_track(comment.track.id), exit_on_fail=kwargs.get("strict_playlist"), **kwargs) logger.info(f"Downloaded all commented tracks of user {user.username}!") + + elif kwargs.get("history"): + """Retrieve all listening history of user""" + # Write string into logger.info that considers -n flag when displaying message. where n is a integer which if None then it will display string empty string + # by copilot + logger.info(f"Retrieving all listening history of user {user.username} {'upto last {} tracks'.format(kwargs.get('n')) if kwargs.get('n') else ''}...") + history = client.get_history(limit=kwargs.get('n')) + for i, track in itertools.islice(enumerate(history.tracks, 1), offset, None): + logger.info(f"track n°{i} of {len(history.tracks)}") + if hasattr(track, "track"): + download_track(client, track.track, exit_on_fail=kwargs.get("strict_playlist"), **kwargs) +# elif hasattr(like, "playlist"): +# download_playlist(client, client.get_playlist(like.playlist.id), **kwargs) + else: + logger.error(f"Unknown history track type {track}") +# if kwargs.get("strict_playlist"): +# sys.exit(1) + logger.info(f"Downloaded all history of user {user.username}!{'upto last {} tracks'.format(kwargs.get('n')) if kwargs.get('n') else ''}...") + elif kwargs.get("t"): logger.info(f"Retrieving all tracks of user {user.username}...") resources = client.get_user_tracks(user.id, limit=1000) @@ -965,6 +979,4 @@ def is_ffmpeg_available(): return shutil.which("ffmpeg") is not None if __name__ == "__main__": -# print("hard fucking") -# exit() main() From 988806763e24c373a75cdf9c6385582b76b99c02 Mon Sep 17 00:00:00 2001 From: CosmicSage Date: Sat, 18 Feb 2023 02:41:36 +0530 Subject: [PATCH 4/6] bug --- scdl/scdl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scdl/scdl.py b/scdl/scdl.py index 5eef61a8..27af29a6 100755 --- a/scdl/scdl.py +++ b/scdl/scdl.py @@ -346,7 +346,7 @@ def download_url(client: SoundCloud, **kwargs): # Write string into logger.info that considers -n flag when displaying message. where n is a integer which if None then it will display string empty string # by copilot logger.info(f"Retrieving all listening history of user {user.username} {'upto last {} tracks'.format(kwargs.get('n')) if kwargs.get('n') else ''}...") - history = client.get_history(limit=kwargs.get('n')) + history = client.get_history(limit=kwargs.get('n') or 1000) for i, track in itertools.islice(enumerate(history.tracks, 1), offset, None): logger.info(f"track n°{i} of {len(history.tracks)}") if hasattr(track, "track"): From 42b3ab795fb39d24d5354803addd1ef27169eff4 Mon Sep 17 00:00:00 2001 From: c0smicsag3x Date: Wed, 21 Feb 2024 21:57:27 +0530 Subject: [PATCH 5/6] New feature config file definition --- scdl/scdl.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scdl/scdl.py b/scdl/scdl.py index 27af29a6..b1f1729b 100755 --- a/scdl/scdl.py +++ b/scdl/scdl.py @@ -6,12 +6,12 @@ scdl (-l | me) [-a | -f | -C | -t | -p | -r][-c | --force-metadata] [-n ][-o ][--hidewarnings][--debug | --error][--path ] [--addtofile][--addtimestamp][--onlymp3][--hide-progress][--min-size ] - [--max-size ][--remove][--no-album-tag][--no-playlist-folder][--history] + [--max-size ][--remove][--no-album-tag][--no-playlist-folder][--config-file ][--history] [--download-archive ][--sync ][--extract-artist][--flac][--original-art] [--original-name][--no-original][--only-original][--name-format ] [--strict-playlist][--playlist-name-format ][--client-id ] [--auth-token ][--overwrite][--no-playlist] - + scdl -h | --help scdl --version @@ -38,6 +38,7 @@ --download-archive [file] Keep track of track IDs in an archive file, and skip already-downloaded files + --config-file [file] Select a configuration file to launch the tool --history Download Listening History --error Set log level to ERROR --extract-artist Set artist tag from title instead of username From e604f5214e999f78efe8db1b9004d2424c0131b7 Mon Sep 17 00:00:00 2001 From: c0smicsag3x Date: Wed, 21 Feb 2024 22:25:54 +0530 Subject: [PATCH 6/6] specify config file to use with --config-file --- scdl/scdl.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scdl/scdl.py b/scdl/scdl.py index b1f1729b..9fd9360b 100755 --- a/scdl/scdl.py +++ b/scdl/scdl.py @@ -147,6 +147,9 @@ def main(): config_file = pathlib.Path(os.environ["XDG_CONFIG_HOME"], "scdl", "scdl.cfg") else: config_file = pathlib.Path.home().joinpath(".config", "scdl", "scdl.cfg") + config_file = pathlib.Path.home().joinpath(".config", "scdl", arguments["--config-file"] or "scdl.cfg") + print(config_file) + # exit() # import conf file config = get_config(config_file)