commit 96912e1c951d9f4d7902da3d64d530cd4da74b5f Author: rra Date: Wed Jun 16 12:00:53 2021 +0200 init diff --git a/streams-feed.py b/streams-feed.py new file mode 100644 index 0000000..5352402 --- /dev/null +++ b/streams-feed.py @@ -0,0 +1,64 @@ +#!/bin/python3 + +#lumbung.space 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 + else: + import re + br = re.compile(r"(\r\n|\r|\n)") + return br.sub(r"
\n", text) + + + +env = jinja2.Environment( + loader=jinja2.FileSystemLoader(os.path.curdir) + ) +env.filters['duration'] = duration +env.filters['linebreaks'] = linebreaks + +host = 'https://tv.lumbung.space' + +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='audio') + +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: + f.write(html) + print(html) + diff --git a/video-feed-prototype.html b/video-feed-prototype.html new file mode 100644 index 0000000..891f7fa --- /dev/null +++ b/video-feed-prototype.html @@ -0,0 +1,405 @@ + + + + + + + lumbung.space video archive prototype + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + + + \ No newline at end of file diff --git a/video-feed.html b/video-feed.html new file mode 100644 index 0000000..e13ad9b --- /dev/null +++ b/video-feed.html @@ -0,0 +1,240 @@ + + + + + + + lumbung.space video archive prototype + + + + + + + + + + + + + + + + + + + + + + + +
+ {% for video in videos %} + + {% endfor %} +
+ + + + \ No newline at end of file diff --git a/video-feed.py b/video-feed.py new file mode 100644 index 0000000..f06d846 --- /dev/null +++ b/video-feed.py @@ -0,0 +1,61 @@ +#!/bin/python3 + +#lumbung.space 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 linebreaks(text): + import re + br = re.compile(r"(\r\n|\r|\n)") + return br.sub(r"
\n", text) + +#def base64ify(url): + #download url to object + #run base64 lib on object + #format a data: string + #return base64string + + +env = jinja2.Environment( + loader=jinja2.FileSystemLoader(os.path.curdir) + ) + +env.filters['duration'] = duration +env.filters['linebreaks'] = linebreaks + +host = 'https://tv.lumbung.space' + +configuration = peertube.Configuration( + host = host+"/api/v1" +) + +client = peertube.ApiClient(configuration) + +v = peertube.VideoApi(client) + +response = v.videos_get(count=6, filter='local') + +videos = response.to_dict() +videos = videos['data'] + +template = env.get_template('video-feed.html') + +html = template.render(videos=videos, host=host, description=description) + +with open('video-feed-prototype.html','w') as f: + f.write(html) + print(html) +