1
0
Fork 0
mirror of https://github.com/MatomoCamp/live-platform.git synced 2024-09-09 04:33:44 +02:00

commit old changes

This commit is contained in:
Lukas Winkler 2023-10-06 19:10:50 +02:00
parent 14faed14cd
commit 693cb31252
Signed by: lukas
GPG key ID: 54DE4D798D244853
2 changed files with 8 additions and 7 deletions

View file

@ -56,17 +56,17 @@ class PeertubeAPI:
}
def get_video(self, id: str) -> "Video":
r = self.s.get(self.api_url + f"/videos/{id}")
r = self.s.get(self.api_url + f"/videos/{id}",headers=self.headers)
r.raise_for_status()
data = r.json()
r2 = self.s.get(self.api_url + f"/videos/{id}/description")
r2 = self.s.get(self.api_url + f"/videos/{id}/description",headers=self.headers)
r2.raise_for_status()
data["description"] = r2.json()["description"]
return Video.from_dict(data, self)
def get_captions(self, id: str) -> Dict[str, Dict[str, Union[str, int]]]:
r = self.s.get(self.api_url + f"/videos/{id}/captions")
r = self.s.get(self.api_url + f"/videos/{id}/captions",headers=self.headers)
r.raise_for_status()
subtitles = {}
for entry in r.json()["data"]:

View file

@ -31,6 +31,7 @@ if not a.access_token:
password = getpass()
a.login(username, password)
exit()
for talk in talks:
if not talk.recording_id_drafts:
@ -40,12 +41,12 @@ for talk in talks:
continue
time.sleep(1)
if sys.argv[1] and talk.id!=sys.argv[1]:
if len(sys.argv) > 1 and talk.id != sys.argv[1]:
continue
print(talk)
# print(talk)
video = a.get_video(talk.recording_id_drafts)
print(talk.archive_name)
project_dir = projects_dir / str(talk.year) / talk.archive_name
print(project_dir)
assert project_dir.exists()
@ -61,7 +62,7 @@ for talk in talks:
remote_captions = a.get_captions(talk.recording_id_drafts)
for lang, subtitle in subtitles.items():
if lang not in remote_captions or subtitle.stat().st_mtime > remote_captions[lang]["timestamp"]:
print("upload")
print(f"upload {subtitle}")
a.upload_caption(talk.recording_id_drafts, lang, subtitle)
if talk.year != 2022: