This commit is contained in:
rra 2021-07-07 17:32:31 +02:00
parent bb83103c00
commit 5a6bb53584

View File

@ -10,7 +10,7 @@ import os
import datetime
import shutil
import requests
from slugify import slugify
import ast
#jinja filters & config
@ -54,7 +54,8 @@ videos = videos['data']
def create_post(post_directory, video_metadata):
global client
global client #lazy
if not os.path.exists(post_dir):
os.mkdir(post_directory)
@ -69,12 +70,13 @@ def create_post(post_directory, video_metadata):
else:
print('image exists')
#FIXME replace the truncated description with the full video description
#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'])
import ast
long_description = ast.literal_eval(api_response)
long_description = ast.literal_eval(api_response)
v['description'] = long_description['description']
with open(os.path.join(post_directory,'index.md'),'w') as f:
post = template.render(v=video_metadata, host=host, preview_image=preview_image)
f.write(post)
@ -91,13 +93,6 @@ template = env.get_template('index_template.md')
existing_posts = os.listdir(output_dir)
#compare returned video uuid to existing posts to determine:
# video - existing post
# 1 0 > create
# 0 1 > delete
# 1 1 > ignore or update
# 0 0 > nothing
for v in videos:
if v['uuid'] not in existing_posts: #if there is a video we dont already have, make it