mirror of
				https://github.com/KevinMidboe/spotify-downloader.git
				synced 2025-10-29 18:00:15 +00:00 
			
		
		
		
	zfill track number metadata
This commit is contained in:
		@@ -185,15 +185,15 @@ def get_arguments(argv=None, base_config_file=spotdl.config.default_config_file)
 | 
			
		||||
        "when YouTube API key is set)",
 | 
			
		||||
        action="store_true",
 | 
			
		||||
    )
 | 
			
		||||
    parser.add_argument(
 | 
			
		||||
        "--processor",
 | 
			
		||||
        default=config["processor"],
 | 
			
		||||
        choices={"synchronous", "threaded"},
 | 
			
		||||
        help='list downloading strategy: - "synchronous" downloads '
 | 
			
		||||
        'tracks one-by-one. - "threaded" (highly experimental at the '
 | 
			
		||||
        'moment! expect it to slash & burn) pre-fetches the next '
 | 
			
		||||
        'track\'s metadata for more efficient downloading'
 | 
			
		||||
    )
 | 
			
		||||
    # parser.add_argument(
 | 
			
		||||
    #     "--processor",
 | 
			
		||||
    #     default=config["processor"],
 | 
			
		||||
    #     choices={"synchronous", "threaded"},
 | 
			
		||||
    #     help='list downloading strategy: - "synchronous" downloads '
 | 
			
		||||
    #     'tracks one-by-one. - "threaded" (highly experimental at the '
 | 
			
		||||
    #     'moment! expect it to slash & burn) pre-fetches the next '
 | 
			
		||||
    #     'track\'s metadata for more efficient downloading'
 | 
			
		||||
    # )
 | 
			
		||||
    parser.add_argument(
 | 
			
		||||
        "-ns",
 | 
			
		||||
        "--no-spaces",
 | 
			
		||||
@@ -258,6 +258,9 @@ def get_arguments(argv=None, base_config_file=spotdl.config.default_config_file)
 | 
			
		||||
        parsed = override_config(parsed.config, parser)
 | 
			
		||||
 | 
			
		||||
    parsed.log_level = log_leveller(parsed.log_level)
 | 
			
		||||
    # TODO: Remove this line once we can experiement with other
 | 
			
		||||
    # download processors (such as "threaded").
 | 
			
		||||
    parsed.processor = "synchronous"
 | 
			
		||||
    return Arguments(parser, parsed)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -22,7 +22,7 @@ DEFAULT_CONFIGURATION = {
 | 
			
		||||
        "dry_run": False,
 | 
			
		||||
        "music_videos_only": False,
 | 
			
		||||
        "no_spaces": False,
 | 
			
		||||
        "processor": "synchronous",
 | 
			
		||||
        # "processor": "synchronous",
 | 
			
		||||
        "output_file": "{artist} - {track-name}.{output-ext}",
 | 
			
		||||
        "search_format": "{artist} - {track-name} lyrics",
 | 
			
		||||
        "youtube_api_key": None,
 | 
			
		||||
@@ -64,7 +64,7 @@ def get_config(config_file):
 | 
			
		||||
            DEFAULT_CONFIGURATION["spotify-downloader"], default_flow_style=False
 | 
			
		||||
        ).split("\n"):
 | 
			
		||||
            if line.strip():
 | 
			
		||||
                log.info(line.strip())
 | 
			
		||||
                logger.info(line.strip())
 | 
			
		||||
        logger.info(
 | 
			
		||||
            "Please note that command line arguments have higher priority "
 | 
			
		||||
            "than their equivalents in the configuration file"
 | 
			
		||||
 
 | 
			
		||||
@@ -174,12 +174,13 @@ class EmbedderDefault(EmbedderBase):
 | 
			
		||||
            audiofile[preset["discnumber"]] = str(metadata["disc_number"])
 | 
			
		||||
        else:
 | 
			
		||||
            audiofile[preset["discnumber"]] = [(metadata["disc_number"], 0)]
 | 
			
		||||
        zfilled_track_number = str(metadata["track_number"]).zfill(len(str(metadata["total_tracks"])))
 | 
			
		||||
        if encoding == "flac":
 | 
			
		||||
            audiofile[preset["tracknumber"]] = str(metadata["track_number"])
 | 
			
		||||
            audiofile[preset["tracknumber"]] = zfilled_track_number
 | 
			
		||||
        else:
 | 
			
		||||
            if preset["tracknumber"] == TAG_PRESET["tracknumber"]:
 | 
			
		||||
                audiofile[preset["tracknumber"]] = "{}/{}".format(
 | 
			
		||||
                    metadata["track_number"], metadata["total_tracks"]
 | 
			
		||||
                    zfilled_track_number, metadata["total_tracks"]
 | 
			
		||||
                )
 | 
			
		||||
            else:
 | 
			
		||||
                audiofile[preset["tracknumber"]] = [
 | 
			
		||||
 
 | 
			
		||||
@@ -9,10 +9,9 @@ def format_string(string, metadata, output_extension="", sanitizer=lambda s: s):
 | 
			
		||||
        "{duration}"     : metadata["duration"],
 | 
			
		||||
        "{year}"         : metadata["year"],
 | 
			
		||||
        "{original-date}": metadata["release_date"],
 | 
			
		||||
        "{track-number}" : metadata["track_number"],
 | 
			
		||||
        "{track-number}" : str(metadata["track_number"]).zfill(len(str(metadata["total_tracks"]))),
 | 
			
		||||
        "{total-tracks}" : metadata["total_tracks"],
 | 
			
		||||
        "{isrc}"         : metadata["external_ids"]["isrc"],
 | 
			
		||||
        # TODO: Call `str.zfill` fill on track-id
 | 
			
		||||
        "{track-id}"     : metadata.get("id", ""),
 | 
			
		||||
        "{output-ext}"   : output_extension,
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user