fix chown for subtitles

This commit is contained in:
simon 2023-04-07 13:11:40 +07:00
parent 5b2d7db102
commit 4038a837cf
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
1 changed files with 7 additions and 3 deletions

View File

@ -115,7 +115,7 @@ class YoutubeSubtitle:
source = subtitle["source"] source = subtitle["source"]
lang = subtitle.get("lang") lang = subtitle.get("lang")
response = requests.get( response = requests.get(
subtitle["url"], headers=requests_headers() subtitle["url"], headers=requests_headers(), timeout=30
) )
if not response.ok: if not response.ok:
print(f"{self.video.youtube_id}: failed to download subtitle") print(f"{self.video.youtube_id}: failed to download subtitle")
@ -137,14 +137,18 @@ class YoutubeSubtitle:
return indexed return indexed
@staticmethod def _write_subtitle_file(self, dest_path, subtitle_str):
def _write_subtitle_file(dest_path, subtitle_str):
"""write subtitle file to disk""" """write subtitle file to disk"""
# create folder here for first video of channel # create folder here for first video of channel
os.makedirs(os.path.split(dest_path)[0], exist_ok=True) os.makedirs(os.path.split(dest_path)[0], exist_ok=True)
with open(dest_path, "w", encoding="utf-8") as subfile: with open(dest_path, "w", encoding="utf-8") as subfile:
subfile.write(subtitle_str) subfile.write(subtitle_str)
host_uid = self.video.config["application"]["HOST_UID"]
host_gid = self.video.config["application"]["HOST_GID"]
if host_uid and host_gid:
os.chown(dest_path, host_uid, host_gid)
@staticmethod @staticmethod
def _index_subtitle(query_str): def _index_subtitle(query_str):
"""send subtitle to es for indexing""" """send subtitle to es for indexing"""