Spaces:
Paused
Paused
File size: 2,301 Bytes
4470ece b37772f 4470ece b8295c9 72aa956 4470ece e0ed190 4470ece e0ed190 4470ece b164694 4470ece dbbe8c4 3d3d1b5 ad91f3e 4470ece e0ed190 8cdc249 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | import os
import requests
import subprocess
import sys
import youtube_dl
from datetime import datetime, timedelta
from moviepy import VideoFileClip
from others import *
def download_pornhub(url, resolusi, nama_channel, judul_video):
download = f"/home/user/app/Hasil Download/Pornhub/{nama_channel}"
if not os.path.exists(download):
os.makedirs(download)
file_name = judul_video + ".mp4"
filename = f'{download}/{file_name}'
subprocess.run(["youtube-dl", "--verbose", "-f", f"bestvideo[height<={resolusi}]+bestaudio/best[height<={resolusi}]", "-o", filename, url])
return filename
def pornhub(url, resolusi_input):
video_info = ""
ydl_opts = {
'quiet': True,
'skip_download': True,
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
info_dict = ydl.extract_info(url, download=False)
if 'formats' in info_dict:
formats = info_dict['formats']
# Process formats here
else:
print('No formats available')
# Filter available formats
resolutions = []
for f in formats:
if 'p' in f['format_id']:
resolutions.append(f['format_id'])
nama_channel = info_dict['uploader']
judul_video = info_dict['title'].replace('/',' ').replace('\\',' ').title()
tanggal_upload = datetime.strptime(info_dict['upload_date'], '%Y%m%d').strftime('%-d %B %Y')
jumlah_viewer = format_number(info_dict['view_count'])
selisih_hari = (datetime.now() - datetime.strptime(info_dict['upload_date'], '%Y%m%d')).days
rata2_viewer_per_hari = format_number(int(info_dict['view_count'] if selisih_hari < 1 else info_dict['view_count'] / selisih_hari))
durasi_video = str(timedelta(seconds=info_dict['duration']))
video_info += f"Nama Channel: {nama_channel}\n"
video_info += f"Judul Video: {judul_video}\n"
video_info += f"Tanggal Upload: {tanggal_upload}\n"
video_info += f"Jumlah Viewer: {jumlah_viewer}\n"
video_info += f"Rata-rata Viewer per Hari: {rata2_viewer_per_hari}\n"
video_info += f"Durasi Video: {durasi_video}\n"
video_info += f"Resolusi yang tersedia: {', '.join(resolutions)}\n"
filename = download_pornhub(url, resolusi_input, nama_channel, judul_video)
return filename, judul_video, video_info
|