Spaces:
Running
Running
File size: 1,200 Bytes
4691839 72aa956 4691839 |
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 |
from bs4 import BeautifulSoup
import re
from others import *
def get_info_bunkrr(soup: BeautifulSoup):
# Mencari judul video di elemen <title>
title = soup.find("title")
if title:
video_title = title.text
# Ubah '&' menjadi '&'
video_title = video_title.replace('&', '&')
# Jika ada karakter '-' maka cari '-' paling belakang dan hapus mulai dari itu sampai ke belakang
if '-' in video_title:
last_dash_index = video_title.rfind('-')
video_title = video_title[:last_dash_index]
# Sisa dari karakter '-' ubah menjadi ' '
video_title = video_title.replace('-', ' ')
# Mencari link download yang berawalan https dan berakhiran .mp4
link_download = soup.find("source", src=re.compile(r'^https.*\.mp4$'))
if link_download:
link_download = link_download['src']
# Ubah '&' menjadi '&'
link_download = link_download.replace('&', '&')
print(link_download)
else:
link_download = ''
return video_title, link_download
else:
print("Tidak ditemukan elemen <title>")
return '', '' |