Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Download all the lyrics of the selected artist to a folder (azapi)
- # ------------------------------------------------------------------
- # Custom script for azapi
- # https://github.com/elmoiv/azapi
- # Script by: Creatide (Sakari Niittymaa - 2023)
- import os
- from azapi import AZlyrics
- import random
- import time
- artist_name = 'nirvana'
- api = AZlyrics()
- api.artist = artist_name
- songs = api.getSongs()
- wait_counter = 0
- # Check whether the specified path exists or not
- artist_folder = artist_name
- isExist = os.path.exists(artist_folder)
- if not isExist:
- # Create a new directory because it does not exist
- os.makedirs(artist_folder)
- print('The new directory "' + artist_name + '" is created!')
- # Get all exist files in artist folder
- exist_files = os.listdir(os.getcwd() + '/' + artist_name)
- # Function to compare if song is already downloadeds
- def is_in_list(string, list_of_strings):
- for i in list_of_strings:
- string = string.casefold().strip()
- i = i.casefold().strip()
- if string in i:
- return True
- return False
- # Generate random wait time in seconds to prevent ban
- def wait_random_seconds(min, max, long_every=0, long_duration=60,):
- wait_time = round(random.uniform(min, max), 2)
- print('Wait: ' + str(wait_time) + 'sec\n')
- time.sleep(wait_time)
- # Longer waiting time every X times
- global wait_counter
- wait_counter += 1
- if wait_counter >= long_every:
- long_duration = round(long_duration + random.uniform(1, 10), 2)
- print('# LONG WAIT: ' + str(long_duration) + 'sec\n')
- time.sleep(long_duration)
- wait_counter = 0
- # Continue only if songs is available
- if type(songs) is dict:
- # Check total number of songs for selected artist
- if len(songs):
- print('Songs in Total: ' + str(len(songs)))
- for song in songs:
- # Check if song is not downloaded already
- if not is_in_list(song, exist_files):
- print(song)
- # Download lyrics and save to artist folder
- api.getLyrics(url=songs[song]["url"], save=True, path=artist_folder)
- wait_random_seconds(4, 12, random.randint(8, 12))
- else:
- print('Song already downloaded: ' + song)
Advertisement
Add Comment
Please, Sign In to add comment