kopia lustrzana https://github.com/Michael-K-Stein/SpotiFile
Fix merge conflict in settings
commit
4ccded1040
|
@ -72,4 +72,4 @@ if __name__ == '__main__':
|
|||
if len(sys.argv) == 1:
|
||||
zip_bunches()
|
||||
else:
|
||||
zip_bunches(sys.argv[1])
|
||||
zip_bunches(sys.argv[1])
|
||||
|
|
|
@ -8,3 +8,4 @@ class Settings:
|
|||
FULL_DOWNLOAD_THREAD_LIMIT = 50
|
||||
VERBOSE_OUTPUTS = False
|
||||
AUTO_DOWNLOAD_PLAYLIST_METADATA = True
|
||||
DOWNLOADS_FILE_SAVE_INTERVAL = 15
|
||||
|
|
|
@ -119,7 +119,7 @@ def save_globals_save_file():
|
|||
f.write( json.dumps(data) )
|
||||
if settings.VERBOSE_OUTPUTS:
|
||||
console.log('Saved globals file!')
|
||||
sleep(15)
|
||||
sleep(settings.DOWNLOADS_FILE_SAVE_INTERVAL)
|
||||
|
||||
|
||||
def full_download(download_dir: str, identifier: str, recursive_artist: bool=False, recursive_album: bool=False, recursive: bool=False, recursive_limit:int=1024, thread_count:int=5):
|
||||
|
@ -133,7 +133,6 @@ def full_download(download_dir: str, identifier: str, recursive_artist: bool=Fal
|
|||
|
||||
client.refresh_tokens()
|
||||
console.log(f'Recieved scrape command on identifier: {identifier}, {recursive=}, {recursive_artist=}, {recursive_album=}, {recursive_limit=}, {thread_count=}')
|
||||
#console.log(f'Scraping on identifier: {identifier} yielded {len(track_list)} tracks!')
|
||||
download_threads = []
|
||||
track_list = []
|
||||
for track in scraper.scrape_tracks(identifier, console=console):
|
||||
|
@ -177,12 +176,11 @@ def download_all_categories_playlists(download_meta_data_only=True, query:str=''
|
|||
random.shuffle(categories)
|
||||
for category_index, category in enumerate(categories):
|
||||
console.log(f'Scraping playlists from category {category.name} ({category_index + 1}/{len(categories)})')
|
||||
#category.download_metadata(scraper=scraper)
|
||||
category.download_metadata(scraper=scraper)
|
||||
try:
|
||||
thread = Thread(target=download_category_playlists, args=(category.spotify_id, category_index, categories, download_meta_data_only))
|
||||
thread.start()
|
||||
threads.append(thread)
|
||||
#download_category_playlists(category_id, category_index=category_index, category_ids=category_ids, download_meta_data_only=download_meta_data_only)
|
||||
except Exception as ex:
|
||||
console.error(f'Scraping categories exception: {ex}')
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class SpotifyScraper:
|
|||
def extract_id_from_link(self, link: str) -> str:
|
||||
return link[link.rindex('/') + 1:]
|
||||
|
||||
def scrape_tracks(self, link: str, console=None) -> list:
|
||||
def scrape_tracks(self, link: str, console=None) -> list[SpotifyTrack]:
|
||||
id_type = self.identify_link_type(link)
|
||||
if id_type == self.IDTypes.Playlist:
|
||||
return self.scrape_playlist_tracks(self.extract_id_from_link(link))
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="/static/css/base.css">
|
||||
<title>Spotifile</title>
|
||||
<title>SpotiFile</title>
|
||||
|
||||
<script>
|
||||
let offset = 0;
|
||||
|
|
|
@ -14,8 +14,11 @@ class SpotifyAlbum:
|
|||
self.load_from_data(album_data)
|
||||
|
||||
def load_from_data(self, data):
|
||||
if not data['album_type']:
|
||||
return
|
||||
self.title = data['name']
|
||||
self.thumbnail_href = data['images'][0]['url']
|
||||
if len(data['images']) > 0:
|
||||
self.thumbnail_href = data['images'][0]['url']
|
||||
self.track_count = data['total_tracks']
|
||||
try:
|
||||
self.release_date = time.mktime(datetime.datetime.strptime(data['release_date'], "%Y-%m-%d").timetuple())
|
||||
|
|
|
@ -48,7 +48,9 @@ class SpotifyTrack:
|
|||
self.explicit = data['explicit']
|
||||
self.href = data['href']
|
||||
self.popularity = data['popularity']
|
||||
self.isrc = data['external_ids']['isrc']
|
||||
if 'isrc' in data['external_ids']:
|
||||
# isrc is not available for local files
|
||||
self.isrc = data['external_ids']['isrc']
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f'SpotifyTrack< {self.title} >'
|
||||
|
@ -65,9 +67,13 @@ class SpotifyTrack:
|
|||
return scraper.get(self.thumbnail_href).content
|
||||
|
||||
def get_download_link(self, scraper) -> str:
|
||||
if not self.isrc:
|
||||
return ''
|
||||
return Deezer.get_track_download_url(Deezer.get_track_data(Deezer.get_track_id_from_isrc(self.isrc)))[0]
|
||||
|
||||
def download(self, scraper) -> bytes:
|
||||
if not self.isrc:
|
||||
raise SpotifyTrackException(f'Cannot download local file {self.title}!')
|
||||
try:
|
||||
download_link = self.get_download_link(scraper)
|
||||
data = Deezer.decrypt_download_data(requests.get(download_link, headers={'Accept':'*/*'}), self.isrc)
|
||||
|
|
Ładowanie…
Reference in New Issue