GilbertClaus commited on
Commit
8c99a28
·
1 Parent(s): 4470ece

Update youtube.py

Browse files
Files changed (1) hide show
  1. youtube.py +18 -14
youtube.py CHANGED
@@ -38,7 +38,7 @@ def format_number(number):
38
  else:
39
  return f"{round(number / 1000000000)} miliar"
40
 
41
- def cut_video(link, resolusi_input, start_time_str, end_time_str):
42
  yt = YouTube(link)
43
  nama_channel = yt.author
44
  judul_video = yt.title.replace('/', '-').replace('\\', '-')
@@ -66,18 +66,22 @@ def cut_video(link, resolusi_input, start_time_str, end_time_str):
66
  return None
67
  else:
68
  filename = download_youtube(stream.url, nama_channel, judul_video, 'mp4')
69
-
70
- start_time_parts = start_time_str.split(':')
71
- end_time_parts = end_time_str.split(':')
72
- start_time_seconds = int(start_time_parts[0]) * 3600 + int(start_time_parts[1]) * 60 + float(start_time_parts[2])
73
- end_time_seconds = int(end_time_parts[0]) * 3600 + int(end_time_parts[1]) * 60 + float(end_time_parts[2])
74
- potong = "/home/user/app/Hasil Potong"
75
- if not os.path.exists(potong):
76
- os.makedirs(potong)
77
- output_file_path = f'{potong}/{judul_video}.mp4'
78
 
79
- with VideoFileClip(filename) as video:
80
- subclip = video.subclip(start_time_seconds, end_time_seconds)
81
- subclip.write_videofile(output_file_path)
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
83
- return video_info, output_file_path, output_file_path
 
38
  else:
39
  return f"{round(number / 1000000000)} miliar"
40
 
41
+ def yt_down(link, resolusi_input, start_time_str, end_time_str):
42
  yt = YouTube(link)
43
  nama_channel = yt.author
44
  judul_video = yt.title.replace('/', '-').replace('\\', '-')
 
66
  return None
67
  else:
68
  filename = download_youtube(stream.url, nama_channel, judul_video, 'mp4')
 
 
 
 
 
 
 
 
 
69
 
70
+ returm filename, judul_video, video_info
71
+
72
+ def yt_cut(link, resolusi_input, start_time_str, end_time_str):
73
+ filename, judul_video, video_info = yt_down(link, resolusi_input, start_time_str, end_time_str)
74
+ start_time_parts = start_time_str.split(':')
75
+ end_time_parts = end_time_str.split(':')
76
+ start_time_seconds = int(start_time_parts[0]) * 3600 + int(start_time_parts[1]) * 60 + float(start_time_parts[2])
77
+ end_time_seconds = int(end_time_parts[0]) * 3600 + int(end_time_parts[1]) * 60 + float(end_time_parts[2])
78
+ potong = "/home/user/app/Hasil Potong"
79
+ if not os.path.exists(potong):
80
+ os.makedirs(potong)
81
+ output_file_path = f'{potong}/{judul_video}.mp4'
82
+
83
+ with VideoFileClip(filename) as video:
84
+ subclip = video.subclip(start_time_seconds, end_time_seconds)
85
+ subclip.write_videofile(output_file_path)
86
 
87
+ return video_info, output_file_path, output_file_path