Browse Source

refactor for legibility

master
rra 3 years ago
parent
commit
c801386dd6
  1. 20
      video-feed.py

20
video-feed.py

@ -70,9 +70,9 @@ def create_post(post_directory, video_metadata):
#replace the truncated description with the full video description
#peertube api is some broken thing in between a py dict and a json file
api_response = peertube.VideoApi(client).videos_id_description_get(v['uuid'])
api_response = peertube.VideoApi(client).videos_id_description_get(video_metadata['uuid'])
long_description = ast.literal_eval(api_response)
v['description'] = long_description['description']
video_metadata['description'] = long_description['description']
with open(os.path.join(post_directory,'index.md'),'w') as f:
@ -112,16 +112,16 @@ template = env.get_template('index_template.md')
existing_posts = os.listdir(output_dir)
for v in videos:
post_dir = os.path.join(output_dir,v['uuid'])
for video_metadata in videos:
post_dir = os.path.join(output_dir, video_metadata['uuid'])
if v['uuid'] not in existing_posts: #if there is a video we dont already have, make it
print('New: ', v['name'], '({})'.format(v['uuid']))
create_post(post_dir, v)
if video_metadata['uuid'] not in existing_posts: #if there is a video we dont already have, make it
print('New: ', video_metadata['name'], '({})'.format(video_metadata['uuid']))
create_post(post_dir, video_metadata)
elif v['uuid'] in existing_posts: # if we already have the video do nothing, possibly update
update_post(post_dir, v)
existing_posts.remove(v['uuid']) # create list of posts which have not been returned by peertube
elif video_metadata['uuid'] in existing_posts: # if we already have the video do nothing, possibly update
update_post(post_dir, video_metadata)
existing_posts.remove(video_metadata['uuid']) # create list of posts which have not been returned by peertube
for post in existing_posts:
print('deleted', post) #rm posts not returned

Loading…
Cancel
Save