mirror of
				https://github.com/THIS-IS-NOT-A-BACKUP/zspotify.git
				synced 2025-11-03 21:10:34 +00:00 
			
		
		
		
	Merge pull request #152 from mockuser404/patch-3
fix podcast existing episodes not skipping
This commit is contained in:
		
						commit
						b22e59fa39
					
				@ -5,11 +5,11 @@ from librespot.audio.decoders import VorbisOnlyAudioQuality
 | 
				
			|||||||
from librespot.metadata import EpisodeId
 | 
					from librespot.metadata import EpisodeId
 | 
				
			||||||
from tqdm import tqdm
 | 
					from tqdm import tqdm
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from const import NAME, ERROR, SHOW, ITEMS, ID, ROOT_PODCAST_PATH, CHUNK_SIZE
 | 
					from const import (CHUNK_SIZE, ERROR, ID, ITEMS, NAME, ROOT_PODCAST_PATH, SHOW,
 | 
				
			||||||
from utils import sanitize_data, create_download_directory, MusicFormat
 | 
					                   SKIP_EXISTING_FILES)
 | 
				
			||||||
 | 
					from utils import create_download_directory, sanitize_data
 | 
				
			||||||
from zspotify import ZSpotify
 | 
					from zspotify import ZSpotify
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
EPISODE_INFO_URL = 'https://api.spotify.com/v1/episodes'
 | 
					EPISODE_INFO_URL = 'https://api.spotify.com/v1/episodes'
 | 
				
			||||||
SHOWS_URL = 'https://api.spotify.com/v1/shows'
 | 
					SHOWS_URL = 'https://api.spotify.com/v1/shows'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -55,11 +55,27 @@ def download_episode(episode_id) -> None:
 | 
				
			|||||||
            ZSpotify.get_config(ROOT_PODCAST_PATH),
 | 
					            ZSpotify.get_config(ROOT_PODCAST_PATH),
 | 
				
			||||||
            extra_paths,
 | 
					            extra_paths,
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					        download_directory = os.path.realpath(download_directory)
 | 
				
			||||||
        create_download_directory(download_directory)
 | 
					        create_download_directory(download_directory)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        total_size = stream.input_stream.size
 | 
					        total_size = stream.input_stream.size
 | 
				
			||||||
        with open(os.path.join(download_directory, f"{filename}.ogg"),
 | 
					
 | 
				
			||||||
                  'wb') as file, tqdm(
 | 
					        filepath = os.path.join(download_directory, f"{filename}.ogg")
 | 
				
			||||||
 | 
					        if (
 | 
				
			||||||
 | 
					            os.path.isfile(filepath)
 | 
				
			||||||
 | 
					            and os.path.getsize(filepath) == total_size
 | 
				
			||||||
 | 
					            and ZSpotify.get_config(SKIP_EXISTING_FILES)
 | 
				
			||||||
 | 
					        ):
 | 
				
			||||||
 | 
					            print(
 | 
				
			||||||
 | 
					                "\n###   SKIPPING:",
 | 
				
			||||||
 | 
					                podcast_name,
 | 
				
			||||||
 | 
					                "-",
 | 
				
			||||||
 | 
					                episode_name,
 | 
				
			||||||
 | 
					                "(EPISODE ALREADY EXISTS)   ###",
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
 | 
					            return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        with open(filepath, 'wb') as file, tqdm(
 | 
				
			||||||
            desc=filename,
 | 
					            desc=filename,
 | 
				
			||||||
            total=total_size,
 | 
					            total=total_size,
 | 
				
			||||||
            unit='B',
 | 
					            unit='B',
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user