You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.2 KiB

#!/bin/python3 video feed generator
#c 2021 roel roscam abbing gpvl3 etc
import peertube
import jinja2
import json
import os
import datetime
def duration(n):
convert '6655' in '1:50:55'
return str(datetime.timedelta(seconds = n))
#def base64ify(url):
#download url to object
#run base64 lib on object
#format a data: string
#return base64string
def linebreaks(text):
if not text:
return text
import re
br = re.compile(r"(\r\n|\r|\n)")
return br.sub(r"<br />\n", text)
env = jinja2.Environment(
env.filters['duration'] = duration
env.filters['linebreaks'] = linebreaks
host = ''
configuration = peertube.Configuration(
host = host+"/api/v1"
client = peertube.ApiClient(configuration)
v = peertube.VideoApi(client)
response = v.videos_get(count=6, filter='local')#, tags_one_of='publish')
videos = response.to_dict()
videos = videos['data']
template = env.get_template('video-feed.html')
html = template.render(videos=videos, host=host)
with open('video-feed-prototype.html','w') as f: