mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 20:00:15 +00:00
chown to fix permissions on new channel folders
This commit is contained in:
parent
563222a26e
commit
8c97e6786a
@ -548,30 +548,25 @@ class VideoDownloader:
|
|||||||
def move_to_archive(self, vid_dict):
|
def move_to_archive(self, vid_dict):
|
||||||
"""move downloaded video from cache to archive"""
|
"""move downloaded video from cache to archive"""
|
||||||
videos = self.config["application"]["videos"]
|
videos = self.config["application"]["videos"]
|
||||||
channel_name = vid_dict["channel"]["channel_name"]
|
host_uid = self.config["application"]["HOST_UID"]
|
||||||
channel_name_clean = clean_string(channel_name)
|
host_gid = self.config["application"]["HOST_GID"]
|
||||||
media_url = vid_dict["media_url"]
|
channel_name = clean_string(vid_dict["channel"]["channel_name"])
|
||||||
youtube_id = vid_dict["youtube_id"]
|
# make archive folder with correct permissions
|
||||||
# make archive folder
|
new_folder = os.path.join(videos, channel_name)
|
||||||
videos = self.config["application"]["videos"]
|
if not os.path.exists(new_folder):
|
||||||
new_folder = os.path.join(videos, channel_name_clean)
|
os.makedirs(new_folder)
|
||||||
os.makedirs(new_folder, exist_ok=True)
|
os.chown(new_folder, host_uid, host_gid)
|
||||||
# find real filename
|
# find real filename
|
||||||
cache_dir = self.config["application"]["cache_dir"]
|
cache_dir = self.config["application"]["cache_dir"]
|
||||||
cached = os.listdir(cache_dir + "/download/")
|
all_cached = ignore_filelist(os.listdir(cache_dir + "/download/"))
|
||||||
all_cached = ignore_filelist(cached)
|
|
||||||
for file_str in all_cached:
|
for file_str in all_cached:
|
||||||
if youtube_id in file_str:
|
if vid_dict["youtube_id"] in file_str:
|
||||||
old_file = file_str
|
old_file = file_str
|
||||||
old_file_path = os.path.join(cache_dir, "download", old_file)
|
old_file_path = os.path.join(cache_dir, "download", old_file)
|
||||||
new_file_path = os.path.join(videos, media_url)
|
new_file_path = os.path.join(videos, vid_dict["media_url"])
|
||||||
# move and fix permission
|
# move media file and fix permission
|
||||||
shutil.move(old_file_path, new_file_path)
|
shutil.move(old_file_path, new_file_path)
|
||||||
os.chown(
|
os.chown(new_file_path, host_uid, host_gid)
|
||||||
new_file_path,
|
|
||||||
self.config["application"]["HOST_UID"],
|
|
||||||
self.config["application"]["HOST_GID"],
|
|
||||||
)
|
|
||||||
|
|
||||||
def delete_from_pending(self, youtube_id):
|
def delete_from_pending(self, youtube_id):
|
||||||
"""delete downloaded video from pending index if its there"""
|
"""delete downloaded video from pending index if its there"""
|
||||||
|
Loading…
Reference in New Issue
Block a user