mirror of
				https://github.com/THIS-IS-NOT-A-BACKUP/zspotify.git
				synced 2025-11-03 21:10:34 +00:00 
			
		
		
		
	Merge branch 'main' of https://github.com/footsiefat/zspotify
This commit is contained in:
		
						commit
						a3e27d4f2a
					
				@ -14,7 +14,7 @@ Requirements:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
Binaries
 | 
					Binaries
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- Python 3.8 or greater
 | 
					- Python 3.9 or greater
 | 
				
			||||||
- ffmpeg*
 | 
					- ffmpeg*
 | 
				
			||||||
- Git**
 | 
					- Git**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,3 +1,4 @@
 | 
				
			|||||||
 | 
					import os
 | 
				
			||||||
from typing import Optional
 | 
					from typing import Optional
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from librespot.audio.decoders import VorbisOnlyAudioQuality
 | 
					from librespot.audio.decoders import VorbisOnlyAudioQuality
 | 
				
			||||||
@ -49,10 +50,11 @@ def download_episode(episode_id) -> None:
 | 
				
			|||||||
        episode_id = EpisodeId.from_base62(episode_id)
 | 
					        episode_id = EpisodeId.from_base62(episode_id)
 | 
				
			||||||
        stream = ZSpotify.get_content_stream(episode_id, ZSpotify.DOWNLOAD_QUALITY)
 | 
					        stream = ZSpotify.get_content_stream(episode_id, ZSpotify.DOWNLOAD_QUALITY)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        create_download_directory(ZSpotify.get_config(ROOT_PODCAST_PATH) + extra_paths)
 | 
					        download_directory = os.path.dirname(__file__) + ZSpotify.get_config(ROOT_PODCAST_PATH) + extra_paths
 | 
				
			||||||
 | 
					        create_download_directory(download_directory)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        total_size = stream.input_stream.size
 | 
					        total_size = stream.input_stream.size
 | 
				
			||||||
        with open(ZSpotify.get_config(ROOT_PODCAST_PATH) + extra_paths + filename + MusicFormat.OGG.value,
 | 
					        with open(download_directory + filename + MusicFormat.OGG.value,
 | 
				
			||||||
                  'wb') as file, tqdm(
 | 
					                  'wb') as file, tqdm(
 | 
				
			||||||
                desc=filename,
 | 
					                desc=filename,
 | 
				
			||||||
                total=total_size,
 | 
					                total=total_size,
 | 
				
			||||||
@ -66,5 +68,3 @@ def download_episode(episode_id) -> None:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        # convert_audio_format(ROOT_PODCAST_PATH +
 | 
					        # convert_audio_format(ROOT_PODCAST_PATH +
 | 
				
			||||||
        #                     extra_paths + filename + '.ogg')
 | 
					        #                     extra_paths + filename + '.ogg')
 | 
				
			||||||
 | 
					 | 
				
			||||||
        # related functions that do stuff with the spotify API
 | 
					 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										11
									
								
								src/track.py
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/track.py
									
									
									
									
									
								
							@ -53,6 +53,7 @@ def get_song_info(song_id) -> tuple[list[str], str, str, Any, Any, Any, Any, Any
 | 
				
			|||||||
# noinspection PyBroadException
 | 
					# noinspection PyBroadException
 | 
				
			||||||
def download_track(track_id: str, extra_paths='', prefix=False, prefix_value='', disable_progressbar=False) -> None:
 | 
					def download_track(track_id: str, extra_paths='', prefix=False, prefix_value='', disable_progressbar=False) -> None:
 | 
				
			||||||
    """ Downloads raw song audio from Spotify """
 | 
					    """ Downloads raw song audio from Spotify """
 | 
				
			||||||
 | 
					    download_directory = os.path.join(os.path.dirname(__file__), ZSpotify.get_config(ROOT_PATH), extra_paths)
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        (artists, album_name, name, image_url, release_year, disc_number,
 | 
					        (artists, album_name, name, image_url, release_year, disc_number,
 | 
				
			||||||
         track_number, scraped_song_id, is_playable) = get_song_info(track_id)
 | 
					         track_number, scraped_song_id, is_playable) = get_song_info(track_id)
 | 
				
			||||||
@ -63,11 +64,11 @@ def download_track(track_id: str, extra_paths='', prefix=False, prefix_value='',
 | 
				
			|||||||
            ) else f'{prefix_value} - {song_name}'
 | 
					            ) else f'{prefix_value} - {song_name}'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ZSpotify.get_config(SPLIT_ALBUM_DISCS):
 | 
					        if ZSpotify.get_config(SPLIT_ALBUM_DISCS):
 | 
				
			||||||
            filename = os.path.join(ZSpotify.get_config(ROOT_PATH), extra_paths, 'Disc ' + str(
 | 
					            filename = os.path.join(download_directory, f'Disc {disc_number}',
 | 
				
			||||||
                disc_number) + '/' + song_name + '.' + ZSpotify.get_config(DOWNLOAD_FORMAT))
 | 
					                                    f'{song_name}.{ZSpotify.get_config(DOWNLOAD_FORMAT)}')
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            filename = os.path.join(ZSpotify.get_config(ROOT_PATH), extra_paths,
 | 
					            filename = os.path.join(download_directory,
 | 
				
			||||||
                                    song_name + '.' + ZSpotify.get_config(DOWNLOAD_FORMAT))
 | 
					                                    f'{song_name}.{ZSpotify.get_config(DOWNLOAD_FORMAT)}')
 | 
				
			||||||
    except Exception:
 | 
					    except Exception:
 | 
				
			||||||
        print('###   SKIPPING SONG - FAILED TO QUERY METADATA   ###')
 | 
					        print('###   SKIPPING SONG - FAILED TO QUERY METADATA   ###')
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
@ -84,7 +85,7 @@ def download_track(track_id: str, extra_paths='', prefix=False, prefix_value='',
 | 
				
			|||||||
                        track_id = scraped_song_id
 | 
					                        track_id = scraped_song_id
 | 
				
			||||||
                    track_id = TrackId.from_base62(track_id)
 | 
					                    track_id = TrackId.from_base62(track_id)
 | 
				
			||||||
                    stream = ZSpotify.get_content_stream(track_id, ZSpotify.DOWNLOAD_QUALITY)
 | 
					                    stream = ZSpotify.get_content_stream(track_id, ZSpotify.DOWNLOAD_QUALITY)
 | 
				
			||||||
                    create_download_directory(ZSpotify.get_config(ROOT_PATH) + extra_paths)
 | 
					                    create_download_directory(download_directory)
 | 
				
			||||||
                    total_size = stream.input_stream.size
 | 
					                    total_size = stream.input_stream.size
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    with open(filename, 'wb') as file, tqdm(
 | 
					                    with open(filename, 'wb') as file, tqdm(
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user