#NEWLINE# def _get_stream_ids( api , user_id , data_directory ) : #NEWLINE# #INDENT# def save_items( items , file_name ) : #NEWLINE# #INDENT# file_path = os . path . join ( data_directory , file_name ) #NEWLINE# with open ( file_path , 'w' ) as file : #NEWLINE# #INDENT# file . write ( json . dumps ( [ i . to_json ( ) for i in items ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# stream_ids = set ( ) #NEWLINE# tags = api . fetch_tags ( ) #NEWLINE# tag_stream_ids = set ( [ t . stream_id for t in tags ] ) #NEWLINE# for system_tag in base . tag_helper . TagHelper ( user_id ) . system_tags ( ) : #NEWLINE# #INDENT# if ( system_tag . stream_id not in tag_stream_ids ) : #NEWLINE# #INDENT# tags . append ( system_tag ) #NEWLINE# tag_stream_ids . add ( system_tag . stream_id ) #NEWLINE# #UNINDENT# #UNINDENT# stream_ids . update ( [ tag . stream_id for tag in tags ] ) #NEWLINE# save_items ( tags , 'tags.json' ) #NEWLINE# subscriptions = api . fetch_subscriptions ( ) #NEWLINE# stream_ids . update ( [ sub . stream_id for sub in subscriptions ] ) #NEWLINE# save_items ( subscriptions , 'subscriptions.json' ) #NEWLINE# friends = api . fetch_friends ( ) #NEWLINE# stream_ids . update ( [ f . stream_id for f in friends if ( f . stream_id and f . is_following ) ] ) #NEWLINE# save_items ( friends , 'friends.json' ) #NEWLINE# bundles = api . fetch_bundles ( ) #NEWLINE# for bundle in bundles : #NEWLINE# #INDENT# stream_ids . update ( [ f . stream_id for f in bundle . feeds ] ) #NEWLINE# #UNINDENT# save_items ( bundles , 'bundles.json' ) #NEWLINE# recommendations = api . fetch_recommendations ( ) #NEWLINE# stream_ids . update ( [ r . stream_id for r in recommendations ] ) #NEWLINE# save_items ( recommendations , 'recommendations.json' ) #NEWLINE# stream_ids . add ( base . api . EXPLORE_STREAM_ID ) #NEWLINE# stream_ids = list ( stream_ids ) #NEWLINE# stream_ids . sort ( reverse = True ) #NEWLINE# return stream_ids