forked from ruangrupa/konfluks
Compare commits
3 Commits
539d3fa6d0
...
f69c092548
Author | SHA1 | Date |
---|---|---|
knoflook | f69c092548 | |
knoflook | 6339724510 | |
knoflook | ab1f8d9d7a |
|
@ -5,6 +5,7 @@ from hashlib import md5
|
|||
from ast import literal_eval as make_tuple
|
||||
from pathlib import Path
|
||||
from urllib.parse import urlparse
|
||||
from re import sub
|
||||
|
||||
import arrow
|
||||
import feedparser
|
||||
|
@ -57,12 +58,12 @@ def create_frontmatter(entry):
|
|||
published = arrow.get(published)
|
||||
|
||||
if "author" in entry:
|
||||
author = entry.author
|
||||
author = sub('"', '\\"', entry.author)
|
||||
else:
|
||||
author = ""
|
||||
|
||||
if "title" in entry:
|
||||
title = entry.title
|
||||
title = sub('"', '\\"', entry.title)
|
||||
else:
|
||||
title = ""
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import os
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from re import sub
|
||||
|
||||
import jinja2
|
||||
import requests
|
||||
|
@ -68,7 +69,9 @@ def create_post(post_directory, post_metadata):
|
|||
|
||||
template_dir = os.path.join(Path(__file__).parent.resolve(), "templates")
|
||||
env = jinja2.Environment(loader=jinja2.FileSystemLoader(template_dir))
|
||||
|
||||
name = post_metadata['account']['display_name']
|
||||
name = sub('"', '\\"', name)
|
||||
post_metadata['account']['display_name'] = name
|
||||
env.filters["localize_media_url"] = localize_media_url
|
||||
env.filters["filter_mastodon_urls"] = filter_mastodon_urls
|
||||
|
||||
|
|
|
@ -100,11 +100,26 @@ def update_post(post_directory, video_metadata, host):
|
|||
|
||||
def main():
|
||||
v = peertube.VideoApi(client)
|
||||
|
||||
response = v.videos_get(count=100, filter="local", tags_one_of="publish")
|
||||
count = 100
|
||||
page = 0
|
||||
response = v.videos_get(count=count, filter="local", tags_one_of="publish", start=page)
|
||||
|
||||
videos = response.to_dict()
|
||||
videos = videos["data"]
|
||||
total = videos['total']
|
||||
videos = videos['data']
|
||||
total -= count
|
||||
if total > 0:
|
||||
to_download = total // count
|
||||
last_page = total % count
|
||||
for i in range(to_download):
|
||||
page += 1
|
||||
response = v.videos_get(count=count, filter="local", tags_one_of="publish", start=page)
|
||||
videos += response.to_dict()['data']
|
||||
if last_page > 0:
|
||||
page += 1
|
||||
response = v.videos_get(count=count, filter="local", tags_one_of="publish", start=page)
|
||||
videos += response.to_dict()['data'][-1*last_page:]
|
||||
|
||||
|
||||
output_dir = os.environ.get("OUTPUT_DIR")
|
||||
|
||||
|
|
Loading…
Reference in New Issue