Added ability to archive videos

This commit is contained in:
2023-03-07 00:07:29 -05:00
parent 9b6e38a313
commit 414cabb9f8
3 changed files with 53 additions and 8 deletions

View File

@ -117,13 +117,47 @@ namespace '/video' do
return "success"
end
get '/:video_id/delete' do
# find the video and delete it
get '/:video_id/archive' do
# find the video
video = Video.where(id: params[:video_id]).first()
FileUtils.rm_rf(video.directory_path)
video.delete()
video_base = File.basename(video.directory_path)
redirect '/video'
# move project to channel's archive
archive_dir = File.join(
video.channel.directory_path,
'Archive',
video_base
)
FileUtils.mv(video.directory_path, archive_dir)
# mark the video as archived and update directory
video.update(
directory_path: archive_dir,
archived: true
)
redirect '/video/' + video.id.to_s()
end
get '/:video_id/unarchive' do
# find the video
video = Video.where(id: params[:video_id]).first()
video_base = File.basename(video.directory_path)
# move project to channel's archive
active_dir = File.join(
video.channel.directory_path,
'Main',
video_base
)
FileUtils.mv(video.directory_path, active_dir)
# mark the video as archived and update directory
video.update(
directory_path: active_dir,
archived: false
)
redirect '/video/' + video.id.to_s()
end
get '/:video_id/edit/script' do