#! /usr/bin/env python import sys sys.path.insert(0, '.') import pandas as pd from tracker.unicorn.spartus_daily import SpartusDaily def get_for_deathbed(): return SpartusDaily( table_prefix='deathbed', artist_id='6bmlMHgSheBauioMgKv2tn', track_id='7eJMfftS33KTjuF7lTsMCx' ) def get_for_canada_goose(): return SpartusDaily( table_prefix='canada_goose', artist_id='2745eLDEFB3uaikXJdol0P', track_id='43ZrTVjee3iMJxf57ZO8WL' ) def get_for_before_i_go(): return SpartusDaily( table_prefix='before_i_go', artist_id='3GxKJzJK4LpsYGXQrw77wz', track_id='6k9s52t7GyxRA4mNDERlwH' ) def get_for_break_my_heart(): return SpartusDaily( table_prefix='break_my_heart', artist_id='3GxKJzJK4LpsYGXQrw77wz', track_id='6jBXavyuyjaCcxSS9eQJf5', daily_listener_table_prefix='before_i_go', ) def get_for_eyes_blue(): return SpartusDaily( table_prefix='eyes_blue', artist_id='1ScHz7wPPxVTEKsc9g3Z0c', track_id='4V7xZ1AiCLwFbNMNc4Gj1f', ) def get_for_carsick(): return SpartusDaily( table_prefix='carsick', artist_id='0ru1ZJNkRRddceqkIah5Yh', track_id='7BVElIiKAbrz8po8BFZf3Q', ) def get_for_love_not_war(): return SpartusDaily( table_prefix='love_not_war', artist_id='1XynjLPAyPi8SZAx8LHN0Z', track_id='4Lt6GXGzYsa1tgkv3nGSTm', ) def get_for_violent(): return SpartusDaily( table_prefix='violent', artist_id='2hiq2iBnUik3mrOfEgRSpB', track_id='7CFfqRW50ffULvBv7lfIIg', ) def get_for_drugs(): return SpartusDaily( table_prefix='drugs', artist_id='1294QqYm1VuxxjRiL9M0h9', track_id='06ioYJ99HHjzRk8HrGfkKS', ) def get_for_jimmy(): return SpartusDaily( table_prefix='jimmy', artist_id='1ScHz7wPPxVTEKsc9g3Z0c', track_id='462d4Jl1AZl1ZlCKwIa22v', ) def get_for_reasons(): return SpartusDaily( table_prefix='reasons', artist_id='3GxKJzJK4LpsYGXQrw77wz', track_id='4kPV7Tx30Ph0tQ4XrhgYCh', ) def get_for_what_other_people(): return SpartusDaily( table_prefix='what_other_people', artist_id='6L1XC7NrmgWRlwAeLJvVtA', track_id='2h9TDNEXRhcDIV3fsoEVq9', ) def get_for_skechers(): # ttps://generic.wg.spotify.com/s4x-insights-api/v1/artist/3O5HD95HTEPgoPFOjAb7yV/recording/4z2JaAVPemYJhFKm7e32RA/timeline/countries?time-filter=28day&aggregation-level=recordi return SpartusDaily( table_prefix='skechers', artist_id='3O5HD95HTEPgoPFOjAb7yV', track_id='2alc8VZAzDgdAsL2QMk3hu' # track_id='4z2JaAVPemYJhFKm7e32RA' ) # table_prefix='canada_goose', # artist_id='2745eLDEFB3uaikXJdol0P', # track_id='43ZrTVjee3iMJxf57ZO8WL' if __name__ == '__main__': getters = { 'deathbed': get_for_deathbed, 'canada_goose': get_for_canada_goose, 'skechers': get_for_skechers, 'before_i_go': get_for_before_i_go, 'break_my_heart': get_for_break_my_heart, 'eyes_blue': get_for_eyes_blue, 'carsick': get_for_carsick, 'love_not_war': get_for_love_not_war, 'violent': get_for_violent, 'drugs': get_for_drugs, 'jimmy': get_for_jimmy, 'reasons': get_for_reasons, 'what_other_people': get_for_what_other_people, } try: trackname = sys.argv[1] accessToken = sys.argv[2] getter = getters[trackname] except (IndexError, KeyError): print(f"\n====\nUsage: run_spartus_daily \nWhere trackname one of {list(getters.keys())} \n") sys.exit(1) include_country_backfill = ((sys.argv[2] if len(sys.argv) > 2 else 'countries') == 'countries') spartus = getter() print(f"Starting Spartus daily update for '{spartus.TABLE_PREFIX}'") if include_country_backfill: print("Backfilling countries as well") else: print("Not backfilling countries") spartus.refresh_request_headers(accessToken) if not spartus.headers.get('authorization'): print("Failed to refresh auth, something is wrong!") # is_ready = spartus.check_data_updated() # if is_ready or True: spartus.main(accessToken, include_country_backfill=True)