dir = os.path.dirname(__file__)
reload(sys)
sys.setdefaultencoding('utf8')
covered_artists_file_path = os.path.join(
    dir, "../../data/assist/covered_artists.txt")
artist_info_file_path = os.path.join(dir,
                                     "../../data/prepared/artist_info.txt")
artists_file_path = os.path.join(dir, "../../data/prepared/artists.txt")
helpers.create_file_if_not_exists(covered_artists_file_path)
helpers.create_file_if_not_exists(artist_info_file_path)

artist_amount = 10000
counter = 0

covered_artists = helpers.read_lines_from_file(covered_artists_file_path)
artist_names = helpers.read_lines_from_file(artists_file_path)

covered_artists_file = open(covered_artists_file_path, "a")
artist_info_file = open(artist_info_file_path, "a")

covered_artists_amount = len(covered_artists)
found_artists_amount = helpers.file_len(artist_info_file_path)

helpers.startProgress("  Fetching next {0} Artists ".format(artist_amount),
                      "  Artists covered: " + str(covered_artists_amount),
                      "  Artists found: " + str(found_artists_amount))

for artist in artist_names:
    if counter >= artist_amount:
        break
sys.setdefaultencoding('utf8')

covered_top_tracks_artists_file_path = os.path.join(
    dir, "../../data/assist/covered_top_tracks_artists.txt")
artists_with_fetched_tracks_file_path = os.path.join(
    dir, "../../data/prepared/artists_with_fetched_tracks.txt")

helpers.create_file_if_not_exists(covered_top_tracks_artists_file_path)
helpers.create_file_if_not_exists(artists_with_fetched_tracks_file_path)

artist_amount = 10000
counter = 0
covered_artists = []
artists = []

covered_artists = helpers.read_lines_from_file(
    covered_top_tracks_artists_file_path)

artist_info_file = open(
    os.path.join(dir, "../../data/prepared/artist_info.txt"), "r")
for line in artist_info_file:
    line = ast.literal_eval(line)
    artists.append({"name": line["name"], "id": line["id"]})
artist_info_file.close()

covered_top_tracks_artists_file = open(covered_top_tracks_artists_file_path,
                                       'a')

artists_with_fetched_tracks_file = open(artists_with_fetched_tracks_file_path,
                                        'a')

covered_artists_amount = len(covered_artists)
reload(sys)
sys.setdefaultencoding('utf8')
covered_artists_file_path = os.path.join(
    dir, "../../data/assist/covered_artists_features.txt")
artist_tracks_features_file_path = os.path.join(
    dir, "../../data/prepared/artist_tracks_features.txt")
artists_with_fetched_tracks_file_path = os.path.join(
    dir, "../../data/prepared/artists_with_fetched_tracks.txt")

helpers.create_file_if_not_exists(covered_artists_file_path)
helpers.create_file_if_not_exists(artist_tracks_features_file_path)

artist_amount = 10000
counter = 0

covered_artists = helpers.read_lines_from_file(covered_artists_file_path)

covered_artists_file = open(covered_artists_file_path, "a")
artist_tracks_features_file = open(artist_tracks_features_file_path, "a")

# Get all artists + tracks
artists = helpers.read_lines_from_file(artists_with_fetched_tracks_file_path)

covered_artists_amount = len(covered_artists)

helpers.startProgress(
    "  Fetching audio features of next {0} Artists ".format(artist_amount),
    "  Artists covered so far: \033[36m{0}\033[0m".format(
        str(covered_artists_amount)))

# loop over artists
示例#4
0
import helpers

dir = os.path.dirname(__file__)
reload(sys)
sys.setdefaultencoding('utf8')

artist_file_path = os.path.join(dir,
                                "../../data/fetched/artists_from_charts.txt")
artist_fetch_last_page_file_path = os.path.join(
    dir, "../../data/assist/artist_fetch_last_page_file.txt")
helpers.create_file_if_not_exists(artist_file_path)
helpers.create_file_if_not_exists(artist_fetch_last_page_file_path)

artist_file = open(artist_file_path, "r")

covered_artists = helpers.read_lines_from_file(artist_file)
artist_file.close()
covered_artists_amount = len(covered_artists)

with open(artist_fetch_last_page_file_path, 'r') as f:
    last_page = f.readline()

if last_page == "":
    last_page = 0
else:
    last_page = int(last_page)

page = last_page
pages = 500
limit = 10