#! /usr/bin/env python import sys sys.path.insert(0, '.') from datetime import datetime, timedelta import random, json from tracker import db, config from tracker.utils import a_datetime from tracker.bangers.defined_tabs import DEFINED_FRUNCHES db.setup_session() if 'localhost' not in str(db.Session.get_bind().url): raise Exception("Unsage to run tests against non local database.") if 'localhost' not in config.es_search_host: raise Exception("Unsage to run against non local elastic search .") from tracker.test.conftest import reset_db reset_db() session = db.Session for user in ['joel', 'test']: if not session.query(db.User).get(user): session.add(db.User(username=user)) from tracker.test import test_data from tracker.test.test_data import fake_youtube, _random_artwork band_names = ''' Enchanter Domain Counterfeit Shutup Integral Form Sophisticated Epoch With The Holding Deed Pudding Progress Snake Hex Red Heart Dandruff Of Stadium Beautiful Pretension Starship Internet'''.split('\n') def maybe_add_feat(title): if random.random() > 0.5: title = title + ' (feat. ' + random.choice(band_names) + ')' return title song_titles = [maybe_add_feat(t) for t in ''' Soft Capriccio The Golden Mountain He Haves Under Minute Many Fits Its Expectations Beyond the Machinations The Inspectors Drink Snickering Patterns Dance Savior Annoyed Souls Hurt Fair Sensitive Rose The Bare Waker No One Organises Above Wraiths She Puts She Serpent Beyond the Telephone The Female Feel Spitting Thoughts Reply Daddy Dying Order Talk Child On The Original Factory Legacy Smiles Of a Drone Tunage On Danger The Naked Toasters The Egyptians of Female The Grass's Diamonds Tower Hear Cure Citizen Paddling Behind Nobody Agent Floundering Controls Free-Flowing Like The Unwilling Nothing Sense Combs In a Act Ear After Us The Free Our Time The Fate of Sand The Smile's Angels Song Organise Inhabitant Letter Shining Above Its Stage Preaching Princesss Duplicate First Rampage The Lethal Mystery Lose My Touch Enjoy My Love No Crazy Free Games I'll Be There For You Baby, I Love You He Heard She's Bad Nobody Succeeds Without Humans I Writes She Center From the Flame The Lock Do Elongating Storms Bring Gravitas Enchanted Intensity Go Go Churra Comrade At The Analytical Fair Trouble Falls Of a Outsider Visions Through Expert The Hard Grunties The Colony of Legacy The Factory's Relationships Endeavors Sell Surgery Revolutionaries Kneeling Through I Brain Chomping Procedures Broken'''.split('\n')] influencers = [ (1000001, 'Influential Records'), (1000002, 'Imi Immery'), (1000003, 'Inmarsat'), ] artists = [ (1, 'Albert'), (2, 'Breakneck'), (3, 'Coordinate Crazy'), (4, 'Dundurns'), (5, 'Euphrates Elsidor'), (6, 'Freddy Frey Finey'), (1001, 'Spornicaty'), (1002, 'Sp. Me. Degulour'), (1003, 'Speak Neezy'), (1004, 'Special Clay'), (101, 'insta_artist1'), (102, 'insta_artist2'), (103, 'insta_artist3'), (104, 'insta_artist4'), (105, 'insta_artist5'), (106, 'insta_non_artist6'), (107, 'insta_non_artist7'), (108, 'insta_non_artist8'), (109, 'insta_non_artist9'), (2001, 'Sound Lord'), (2002, 'Sounds Strong'), (2003, 'Sounds Like A Plan'), (2004, 'Sound & Furry'), (2005, 'Sound Significanto'), (2006, 'Soundy Cloudy'), (2007, 'Sound Orange'), (2008, 'Sound Apple'), (2009, 'Sound Weapon'), ] insta_bios = { 101: 'A musician', 102: 'A musician', 103: 'A musician', 104: 'A musician', 105: 'A musician', 106: 'A musician', 107: 'A musician', 108: 'A musician', 109: 'A musician', } insta_urls = { 101: None, 102: 'https://open.spotify.com/album/an_album', 103: 'https://soundcloud.com/awesomeness', 104: None, 105: None, 106: None, 107: None, 108: None, 109: None, } listner_cities = [ ('Chicago', 'IL', 'US'), ('Sacramento', 'CA', 'US'), ('Los Angeles', 'CA', 'US'), ('London', 'ENG', 'UK'), ('Birmingham', 'ENG', 'UK'), ('Toronto', 'ON', 'CA'), ('Vancouver', 'BC', 'CA'), ('New York', 'NY', 'US'), ('San Francisco', 'CA', 'US'), ('Paris', '', 'FR'), ('Mexico City', '', 'MX'), ('Stockholm', 'AB', 'SE'), ('Gothenburg', 'O', 'SE'), ('Karlstad', 'S', 'SE'), ('Västerås', 'U', 'SE'), ('Gävle', 'X', 'SE'), ('Santiago', 'RM', 'CL'), ('Sydney', 'NSW', 'AU'), ('Prague', '10', 'CZ'), ('Oslo', '03', 'NO'), ('Brisbane', 'QLD', 'AU'), ('Melbourne', 'VIC', 'AU'), ('Budapest', 'BU', 'HU'), ] listener_playlist_names = [ " ".join(sorted(" ".join(random.choices(band_names, k=2)).split(" "))) for _ in range(4) ] tracks = { 1: [(id, random.choice(song_titles)) for id in range(11, 19)], 2: [(21, random.choice(song_titles)), (22, random.choice(song_titles))], 4: [(41, random.choice(song_titles)), (42, random.choice(song_titles))], 1001: [(id, random.choice(song_titles)) for id in range(11001, 11001+100)], 1002: [(id, random.choice(song_titles)) for id in range(12001, 12001+20)], 1003: [(id, random.choice(song_titles)) for id in range(13001, 13001+20)], 1004: [(id, random.choice(song_titles)) for id in range(13001, 13001+20)], 2001: [(id, random.choice(song_titles)) for id in range(21001, 21001+5)], 2002: [(id, random.choice(song_titles)) for id in range(22001, 22001+5)], 2003: [(id, random.choice(song_titles)) for id in range(23001, 23001+5)], 2004: [(id, random.choice(song_titles)) for id in range(24001, 24001+5)], 2005: [(id, random.choice(song_titles)) for id in range(25001, 25001+5)], 2006: [(id, random.choice(song_titles)) for id in range(26001, 26001+5)], 2007: [(id, random.choice(song_titles)) for id in range(27001, 27001+5)], 2008: [(id, random.choice(song_titles)) for id in range(28001, 28001+5)], 2009: [(id, random.choice(song_titles)) for id in range(29001, 29001+5)], } yt_videos = { } _tw = [1, 2, 3, 4, 5, 6, 1000001, 1000002, 1000003] _in = [1, 2, 3, 4, 5, 6, 1000001, 1000002, 1000003, 101, 102, 103, 104] _spy = [1, 2, 3, 4, 5, 6, 1000001, 1000002, 1000003, 1000, 1001, 1002, 1003] _sc = [1, 2, 3, 4, 5, 6, 1000001, 1000002, 1000003] + list(range(2001, 2010)) _yt_artists = [1, 2, 3] _yt = [1000001, 1000002, 1000003] def _make_spyid_for_listner_name(name): words = name.split(' ') spyid = 'lstn' + "".join([w[:3] for w in words]) + str(len(words)) + str(len(name)) return spyid for name in listener_playlist_names: session.add(db.SpyPlaylist( spyid=_make_spyid_for_listner_name(name), name=name, )) session.flush() for id, name in artists + influencers: print("(id, name)", (id, name)) kw = {} username = name.lower().replace(' ', '') is_influencer = id >= 1000000 if id in _yt_artists: ytid = 'yt{}'.format(id) session.add(db.YtArtistChannel( ytid=ytid, name=name, data=fake_youtube.channel.item(ytid=ytid, title=name) )) session.flush() last = random.randint(1000, 1000000) for i in range(50): session.add(db.YtArtistChannelStat( artist_channel_ytid=ytid, as_of=(datetime.today() - timedelta(days=i)).date(), subscriber_count=last - random.randint(int(last/4), int(last/2)), view_count=last, comment_count=int(last/10), video_count=10, )) last = last * (0.8 + random.random() * 0.2) if id in _tw: session.add(db.TrackedEntity( eid=id, twitter_id=str(id), name=name, is_influencer=is_influencer, twitter_data=test_data.make_twitter_user_json(name=name, screen_name=username))) session.flush() last = random.randint(1000, 1000000) for i in range(50): session.add(db.TwStats( eid=id, as_of=datetime.today() - timedelta(days=i), listed_count=last, friends_count=last, statuses_count=last, followers_count=last, favourites_count=last, )) last = last * (0.8 + random.random() * 0.2) if is_influencer: session.add(db.UsersTwInfluencers(eid=id, username='joel')) session.add(db.UsersTwInfluencers(eid=id, username='test')) if id in _in: biography = '' in_data = test_data.make_insta_user_json( full_name=name, biography=insta_bios.get(id), external_url=insta_urls.get(id)) session.add(db.InUser( inid=username, is_influencer=is_influencer, page_data=in_data, data_last_updated=datetime.today(), )) session.flush() last = random.randint(1000, 1000000) for i in range(50): session.add(db.InStats( inid=username, as_of=datetime.today() - timedelta(days=i), followed_by_count = last * 10, follows_count= int(last / 10), )) last = last * (0.8 + random.random() * 0.2) if is_influencer: session.add(db.UsersInInfluencers(username='joel', inid=username)) session.add(db.UsersInInfluencers(username='test', inid=username)) if id in _spy: last = random.randint(1000, 10000) session.add(db.SpyArtist( spyid=str(id), name=name, data=test_data.make_spy_artist_json( name=name, id=id, follower_count=last) )) session.flush() last_pop = random.randint(11, 65) for i in range(50): session.add(db.SpyArtistMetrics( artist_spyid=str(id), as_of=datetime.today() - timedelta(days=i), followers=last * 10, popularity=random.randint(11, 65), )) last = last * (0.95 + random.random() * 0.05) session.flush() last_pop = random.randint(11, 65) for i in range(50): if random.random() < 0.666: continue as_of = (datetime.today() - timedelta(days=i)).date() cities = sorted([ (random.randint(1000, 100000), name, region, country) for name, region, country in random.sample(listner_cities, 8) ]) playlists = sorted([ (random.randint(1000, 100000), name) for name in random.sample(listener_playlist_names, 3) ]) session.add(db.SpyArtistListeners( artist_spyid=str(id), as_of=as_of, global_chart_position=0 if random.random() > 0.6 else random.randint(10, 200), monthly_listeners=int(max(cities[0][0], playlists[0][0])*9.343), monthly_listeners_delta=random.randint(-2000, 2000), playlist0_listeners=playlists[0][0], playlist0_spyid=_make_spyid_for_listner_name(playlists[0][1]), playlist1_listeners=playlists[1][0], playlist1_spyid=_make_spyid_for_listner_name(playlists[1][1]), playlist2_listeners=playlists[2][0], playlist2_spyid=_make_spyid_for_listner_name(playlists[2][1]), city0_listeners=cities[0][0], city0_name=cities[0][1], city0_country=cities[0][2], city0_region=cities[0][3], city1_listeners=cities[1][0], city1_name=cities[1][1], city1_country=cities[1][2], city1_region=cities[1][3], city2_listeners=cities[2][0], city2_name=cities[2][1], city2_country=cities[2][2], city2_region=cities[2][3], )) for listeners, name, region, country in cities: session.add(db.SpyArtistListenerCity( artist_spyid=str(id), as_of=as_of, name=name, region=region, country=country, listeners=listeners )) for listeners, name in playlists: session.add(db.SpyArtistListenerPlaylist( artist_spyid=str(id), as_of=as_of, playlist_spyid=_make_spyid_for_listner_name(name), listeners=listeners )) session.flush() for track_id, track_name in tracks.get(id, []): album_name = 'Songs for ' + random.choice(song_titles) current_popularity = random.randint(33, 75) session.add(db.SpyTrack( spyid=str(track_id), name=track_name, primary_artist_spyid=str(id), data=test_data.make_spy_track_json( id=track_id, name=track_name, artist_name=name, album_name=album_name, popularity=current_popularity, ), album_data=test_data.make_spy_album_json( name=album_name, ))) session.flush() for i in range(30): session.add(db.SpyTrackPopularity( track_spyid=str(track_id), as_of=datetime.today() - timedelta(days=i), value=random.randint(33, 75) if i < 29 else current_popularity, )) session.add(db.SpyTrackStreamEstimate(spyid=str(track_id), streams=random.randint(1000, 5e8), input_data={})) if random.random() > 0.3: # Add videod for the track ytid = 'spy' + str(track_id) video_title = track_name + ' - ' + name published = datetime.today() - timedelta(days=random.randint(5, 14)) video_data = fake_youtube._snippet( title=video_title, publishedAt=published.isoformat() + "Z", ) session.add(db.YtVideo( ytid=ytid, title=video_title, published=published, track_spyid=str(track_id), artist_spyid=str(id), api_data=fake_youtube.video_item(id=ytid, snippet=video_data, contentDetails=fake_youtube._contentDetails()) )) session.flush() last = random.randint(1000, 10000000) for j in range(30): session.add(db.YtVideoStatistics( video_ytid=ytid, as_of=datetime.today() - timedelta(days=j), like_count=last, dislike_count=last * random.random(), view_count=last * random.randint(2, 20), favorite_count=last * random.random(), comment_count=last * random.random(), )) last = last * (0.9 + random.random() * 0.1) if id in _sc: last = random.randint(1000, 10000) session.add(db.ScUser( scid=id, name=name, is_influencer=is_influencer, data=test_data.make_soundcloud_user_json( id=id, username=username, full_name=name, followers_count=last * 4) )) session.flush() for i in range(50): session.add(db.ScArtistStats( artist_scid=id, as_of=datetime.today() - timedelta(days=i), followers_count=last * 4, followings_count=int(last / 10), track_count=len(tracks.get(id, [])), playlist_count=1, public_favorites_count=1 )) last = last * (0.9 + random.random() * 0.1) for track_id, track_name in tracks.get(id, []): created_days_ago = random.randint(3, 50) if random.random() < 0.7 else 1 # need some 'new' tracks track = test_data.make_soundcloud_track_json( id=track_id, title=track_name, user_id=id, user_permalink=username, created_at=(datetime.today() - timedelta(days=created_days_ago)).isoformat(), ) sc_track = db.ScTrack( scid=track_id, artist_scid=id, name=track['title'], data=track, created_at=track.get('created_at'), duration=track.get('duration'), genre=track.get('genre'), ) session.add(sc_track) last = random.randint(1000, 1000000) last_comment = random.randint(50, 300) last_favoritings = random.randint(120, 5000) for i in range(created_days_ago): session.add(db.ScTrackStats( track_scid=track_id, as_of=datetime.today() - timedelta(days=i), playback_count=last*10, download_count=last, favoritings_count=last_favoritings, comment_count=last_comment, )) last = last * (0.9 + random.random()*0.1) last_comment = int(last_comment * (0.85 + random.random()*0.15)) last_favoritings = int(last_favoritings * (0.85 + random.random()*0.15)) sc_track.last_playback_count = last*10 sc_track.last_comment_count = last_comment sc_track.last_favoritings_count = last_favoritings if is_influencer: session.add(db.UsersScInfluencers( username='joel', scid=id, )) session.add(db.UsersScInfluencers( username='test', scid=id, )) session.flush() for id, name in influencers: if id in _spy: session.add(db.SpyPlaylist( spyid=str(id), name=name, user=username, added=a_datetime('40 days ago'), data=test_data.make_spy_playlist_json(followers_count=int(random.random()*500000), id=id, name=(name + " Top Tracks"), user_name=name), country_code=random.choice(['UK', 'US', 'AU', 'CA']), daily_streams=random.randint(10, 100000), pct_uk_streams=random.random(), )) session.add(db.UsersSpyPlaylists( username='joel', spyid=str(id), )) session.add(db.UsersSpyPlaylists( username='test', spyid=str(id), )) if id in _yt: channel_id = str(id) session.add(db.YtChannel( ytid=channel_id, name=name + ' Videos', )) session.flush() session.add(db.UsersYtChannels( username='joel', ytid=channel_id, )) session.add(db.UsersYtChannels( username='test', ytid=channel_id, )) for i in range(random.randint(5, 14)): video_ytid = channel_id + 'X' + str(i) days = random.randint(20, 110) session.add(db.YtVideo( ytid=video_ytid, title=random.choice(song_titles) + ' ' + random.choice(song_titles) + (" (feat. {})".format(random.choice(band_names)) if random.random() > 0.4 else ''), first_seen=datetime.today() - timedelta(days=days), published=datetime.today() - timedelta(days=days+1), )) session.flush() session.add(db.YtChannelVideo( channel_ytid=channel_id, video_ytid=video_ytid, )) last = random.randint(1000, 10000000) for j in range(days): session.add(db.YtVideoStatistics( video_ytid=video_ytid, as_of=datetime.today() - timedelta(days=j), like_count=last, dislike_count=last*random.random(), view_count=last*random.randint(2, 20), favorite_count=last*random.random(), comment_count=last*random.random(), )) last = last * (0.9 + random.random() * 0.1) session.flush() for i, r in enumerate( session.execute('select pl.spyid, t.spyid from spy_playlist pl, spy_tracks t ').fetchall()): playlist_spyid, track_spyid = r session.add(db.SpyPlaylistTrack( playlist_spyid=playlist_spyid, track_spyid=track_spyid, added_at=a_datetime('100 days ago'), first_seen=a_datetime('2 days ago'), last_seen=a_datetime('1 days ago'), first_position=i, last_position=i, )) session.flush() # Add more spotify playlists. for count in range(10): id = 'otherpl{}'.format(count) playlist_name = 'The {} of Hot Tracks'.format(id) session.add(db.SpyPlaylist( spyid=id, name=playlist_name, user='joel', added=a_datetime('40 days ago'), data=test_data.make_spy_playlist_json(followers_count=int(random.random() * 500000), id=id, name=playlist_name, user_name='joel'), country_code=random.choice(['UK', 'US', 'CA']), daily_streams=random.randint(10, 100000), pct_uk_streams=random.random(), )) session.flush() for (track_id,) in session.execute('select spyid from spy_tracks'): if random.random() > 0.7: session.add(db.SpyPlaylistTrack( playlist_spyid=id, track_spyid=track_id, added_at=a_datetime('100 days ago'), first_seen=a_datetime('2 days ago'), last_seen=a_datetime('1 days ago'), first_position=1, last_position=1, )) session.flush() # Insert official chart records for some spotify tracks. def insert_spy_official_charts(): from tracker.utils import chunks def myshuffle(lst, chunksize): # shuffle in chunks, so that we don't make moves that are too big. return sum([random.sample(l, len(l)) for l in list(chunks(lst, chunksize))], []) from tracker.spotify_charts import all_country_codes for (iso2, country_name) in all_country_codes: spyids = random.sample([r[0] for r in session.execute('select spyid from spy_tracks')], 50) for day in range(20): streams = random.randint(2e6, 3e7) for position, spyid in enumerate(spyids, start=1): session.add(db.SpyOfficialChart( country_code=iso2, as_of=(datetime.today() - timedelta(days=day)).date(), spyid=spyid, position=position, streams=streams )) session.flush() streams = streams - random.randint(20000, 60000) spyids = myshuffle(spyids, chunksize=5) insert_spy_official_charts() for i, r in enumerate( session.execute('select i.scid, a.scid from sc_users i, sc_users a ' 'where not a.is_influencer and i.is_influencer').fetchall()): inf, art = r session.add(db.ScFollowing( influencer_scid=inf, artist_scid=art, seen_at=datetime.today() - timedelta(days=random.randint(0, 15)), )) session.flush() for i, r in enumerate( session.execute('select i.inid, a.inid from in_user i, in_user a ' 'where not a.is_influencer and i.is_influencer').fetchall()): inf, art = r session.add(db.InFollow( followed_by_inid=inf, followee_inid=art, first_seen=a_datetime('2 days ago'), )) session.flush() for i, r in enumerate( session.execute('select i.eid, a.eid from tracked_entities i, tracked_entities a ' 'where not a.is_influencer and i.is_influencer').fetchall()): inf, art = r session.add(db.Following( influencer_eid=inf, followee_eid=art, seen_at=a_datetime('2 days ago'), )) session.flush() from tracker.artists import create_association_by_ids create_association_by_ids(scid=1, eid=1) create_association_by_ids(scid=2, inid='breakneck', spyid='2') create_association_by_ids(scid=3, eid=3, spyid='3') session.execute(''' alter sequence tracked_entities_eid_seq RESTART WITH 10000 ''') # seed tiktok data db.Session.add(db.TikTokUser(ttid='1', unique_id='tiktok1', nickname='Tikki Toks', is_influencer=True, cover_image_url=_random_artwork('Tikki Toks'))) db.Session.add(db.TikTokUser(ttid='2', unique_id='tiktok2', nickname='Bego Nethot', is_influencer=True, cover_image_url=_random_artwork('Bego Nethot'))) db.Session.add(db.TikTokUser(ttid='3', unique_id='tiktok3', nickname='Memer', is_influencer=True, cover_image_url=_random_artwork('Memer'))) db.Session.add(db.UsersTtInfluencers(username='joel', unique_id='tiktok1')) db.Session.add(db.UsersTtInfluencers(username='joel', unique_id='tiktok2')) db.Session.add(db.UsersTtInfluencers(username='joel', unique_id='tiktok3')) db.Session.flush() sound_titles = [ "He Heard She's Bad", "Nobody Succeeds Without Humans", "I Writes She", "Center From the Flame", "The Lock Do", "Elongating Storms", "Bring Gravitas", "Fantastic Tomorrow", "Sweetie", "Smile For Me", "Remember Me", "She Heard We Can’t Stop", ] author_names = ['Funny Toker', 'Lame Toker', 'Carnie Toker', 'Lyme Disease'] for i in range(len(sound_titles) + 10): ttid = str((i + 1) * 100) new_sound = db.TikTokSound( ttid=ttid, title=sound_titles[i] if len(sound_titles) > i else 'original sound', author=random.choice(author_names), first_seen=datetime.today() - timedelta(days=random.randint(0, 10)), ) if random.random() < 0.3: new_sound.last_posts = None new_sound.last_visited = None new_sound.web_url = None new_sound.cover_image_url = None else: new_sound.last_posts = random.randint(100, 2000) new_sound.last_visited = datetime.today() - timedelta(hours=4), new_sound.web_url = f"https://www.tiktok.com/music/fakesound-${ttid}" new_sound.cover_image_url = f"https://picsum.photos/100/100?random=${ttid}" if random.random() < 0.2: new_sound.has_trended = True db.Session.add(new_sound) db.Session.flush() for j in range(1, random.randint(2,10)): db.Session.add( db.TikTokVideo( ttid=f'{i*1000+j}', sound_ttid=ttid, author_ttid=random.choice(['1', '2', '3']), last_digg_count=random.randint(10, 1000), created_at=datetime.today() - timedelta(days=random.randint(0, 10)), cover_image_url=f"https://picsum.photos/100/100?random=${ttid}", )) db.Session.flush() other_trending_sounds = [ "Days For The Gang", "World For Business", "Appeal For Tomorrow", "Hands Up Of Cash", "Whisper Your Time", "With His Lyrics", "Crossroads Of Your Song", "Bring On That Streets", "Walking And Choice", "Best And Cash", "No And Chances", "Beat And Rhymes", "Put Your Hands Up", "Baby, Thanks Fo' Nuthin'", ] for i, title in enumerate(other_trending_sounds): db.Session.add(db.TikTokSound( ttid=f'{i*10000}', title=title, author=random.choice(band_names), first_seen=datetime.today() - timedelta(days=random.randint(0, 10)), has_trended=True, last_posts = random.randint(100, 2000), last_visited = datetime.today() - timedelta(hours=random.randint(0, 40)), )) db.Session.commit() CHARTS = [ { "id": "whitelist1", "bg": "tiktok1", "title": "Trending on TikTok", "subtitle": "Sounds recently seen as trending.", "nextApi": "/api/charts/tiktok", }, { "id": "whitelist2", "bg": "whitelist1", "title": "Listen To This US 🇺🇸!", "subtitle": "The most important US tracks on The Whitelist right now.", "nextApi": "/api/charts/curated/top5us", }, { "id": "spotify2", "bg": "spotify1", "title": "New and Popular on Spotify", "subtitle": "The most popular unsigned tracks released in the last 10 days", "nextApi": "/api/charts/SpotifyEmerging", }, { "id": "soundcloud1", "bg": "soundcloud1", "title": "SoundCloud 10\u00A0by\u00A010", "subtitle": "Tracks reaching 10k streams in their first 10 days.", "nextApi": "/api/charts/SoundCloudNewTracks", "apiSettings": { "publishedDaysAgo": 10, "minPlays": 10000, "isScouted": True, "maxFollowers": 1000000, "countries": None, }, }, { "id": "soundcloud3", "bg": "soundcloud1", "title": "SoundCloud 10\u00A0by\u00A010 US & Can", "subtitle": "🇺🇸 🇨🇦 US and Canadian tracks reaching 10k streams in their first 10 days.", "nextApi": "/api/charts/SoundCloudNewTracks", "apiSettings": { "filters": { "publishedDaysAgo": 10, "minPlays": 10000, "isScouted": True, "maxFollowers": 1000000, "countries": ["US", "CA"], } }, }, { "id": "soundcloud4", "bg": "soundcloud1", "title": "SoundCloud My Scouts", "subtitle": "SoundCloud from your scouts.", "nextApi": "/api/charts/SoundCloudMyScoutings", "apiSettings": {}, }, { "id": "instagram2", "bg": "instagram1", "title": "Your Insta Scoutings", "subtitle": "New follows by your scouts.", "nextApi": "/api/charts/InstagramMyScoutings", }, { "id": "instagram1", "bg": "instagram1", "title": "Instagram Exploders", "subtitle": "Artists getting a lot of new followers on Instagram.", "nextApi": "/api/charts/InstagramFollowerJump", }, { "id": "YouTubeNew", "bg": "youtube1", "title": "New-Tube", "subtitle": "Videos published recently and getting early buzz", "nextApi": "/api/charts/YouTubeNew", }, { "id": "mostscouted1", "bg": "whitelist1", "title": "Most Scouted Recently", "subtitle": "Scoutings in the last 60 days.", "nextApi": "/api/charts/MostScoutedRecently", }, { "id": "spotify1", "bg": "spotify1", "title": "Emerging on Spotify", "subtitle": "Popular songs from artists not signed to a major.", "nextApi": "/api/charts/SpotifyEmerging ", }, { "id": "spotifyofficial", "bg": "spotify1", "title": "Spotify Official 200", "subtitle": "Top 200 streamers from Spotify Charts.", "nextApi": "/api/charts/SpotifyOfficialChart", }, ] db.Session.add(db.CuratedList(list_id='top5', name='Top 5')) db.Session.flush() db.Session.add(db.CuratedListItem( list_id='top5', track_scid=db.Session.execute('select scid from sc_tracks limit 1').fetchall()[0][0], )) db.Session.add(db.CuratedListItem( list_id='top5', video_ytid=db.Session.execute('select ytid from yt_videos limit 1').fetchall()[0][0] )) for chart in CHARTS: session.execute(""" insert into charts (id, title, subtitle, background_id, api_path, public, api_settings) values (:id, :title, :subtitle, :bg, :nextApi, true, (:apiSettings)::jsonb) """, params=dict( chart, apiSettings=( json.dumps(chart.get("apiSettings")) if chart.get("apiSettings") else None ), ), ) joel = db.Session.query(db.User).get('joel') joel.hidden_artist_keys = ['in/4'] session.commit() from tracker.artists import create_association_by_ids create_association_by_ids(scid=1, spyid='1', eid=1, inid='albert', ytid='yt1') from tracker import runner runner.update_materialized_views() from tracker.db import daily_stats daily_stats.initialise_everything_ftw() from tracker import search search.sync_yt_videos() search.sync_sc_tracks() search.sync_spy_tracks() from tracker import soundcloud_analyzer soundcloud_analyzer.upsert_sc_track_regressions(num_partitions=100) db.Session.commit()