Spaces:
Building
Building
GilbertClaus
commited on
Commit
•
499c0c0
1
Parent(s):
78491c4
Sakura
Browse files
others.py
CHANGED
@@ -5,6 +5,18 @@ import re
|
|
5 |
import time
|
6 |
import requests
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
def sesi(info, lokasi_file):
|
9 |
st.session_state.info = info
|
10 |
st.session_state.lokasi_file = lokasi_file
|
@@ -63,24 +75,86 @@ def link_redirect(url):
|
|
63 |
|
64 |
return info
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
def format_info(info):
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
#
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
return info
|
|
|
5 |
import time
|
6 |
import requests
|
7 |
|
8 |
+
from bs4 import BeautifulSoup
|
9 |
+
import requests
|
10 |
+
import json
|
11 |
+
import os
|
12 |
+
import math
|
13 |
+
import re
|
14 |
+
import subprocess
|
15 |
+
import shutil
|
16 |
+
from collections import defaultdict
|
17 |
+
from tqdm import tqdm
|
18 |
+
import urllib.parse
|
19 |
+
|
20 |
def sesi(info, lokasi_file):
|
21 |
st.session_state.info = info
|
22 |
st.session_state.lokasi_file = lokasi_file
|
|
|
75 |
|
76 |
return info
|
77 |
|
78 |
+
def get_digits(thumbnail_url):
|
79 |
+
if 'cospuri' in thumbnail_url:
|
80 |
+
# Extract digits from thumbnail_url
|
81 |
+
match = re.search(r'/0(\d{3})', thumbnail_url)
|
82 |
+
if match:
|
83 |
+
digits = match.group(1)
|
84 |
+
print(f"Kode Digit: {digits}")
|
85 |
+
return digits
|
86 |
+
else:
|
87 |
+
return ''
|
88 |
+
elif 'fellatiojapan' in thumbnail_url or 'spermmania' in thumbnail_url:
|
89 |
+
# Extract digits from thumbnail_url
|
90 |
+
match = re.search(r'/(\d+)_', thumbnail_url)
|
91 |
+
if match:
|
92 |
+
digits = match.group(1)
|
93 |
+
print(f"Kode Digit: {digits}")
|
94 |
+
return digits
|
95 |
+
else:
|
96 |
+
return ''
|
97 |
+
else:
|
98 |
+
return ''
|
99 |
+
|
100 |
+
def get_video_info(url):
|
101 |
+
response = requests.get(url)
|
102 |
+
soup = BeautifulSoup(response.text, 'html.parser')
|
103 |
+
# Mencari judul video di elemen meta dengan name="twitter:title"
|
104 |
+
title = soup.find("meta", attrs={"name": "twitter:title"})
|
105 |
+
if title:
|
106 |
+
video_title = title['content']
|
107 |
+
|
108 |
+
# Hapus semua karakter yang terdapat di dalam kurung siku (termasuk angka)
|
109 |
+
video_title = re.sub(r'\[[^\]]*\]', '', video_title)
|
110 |
|
111 |
+
# Hapus kata 'Cosplay '
|
112 |
+
video_title = video_title.replace('Cosplay ', '')
|
113 |
+
|
114 |
+
# Tukar posisi kalimat yang dipisahkan oleh ' - '
|
115 |
+
if ' - ' in video_title:
|
116 |
+
parts = video_title.split(' - ')
|
117 |
+
actress = parts[0].lstrip().replace("'s", "")
|
118 |
+
series = parts[1].lstrip()
|
119 |
+
else:
|
120 |
+
actress = ''
|
121 |
+
series = ''
|
122 |
+
|
123 |
+
print(f"Series: {series}")
|
124 |
+
print(f"Artis: {actress}")
|
125 |
+
return actress, series
|
126 |
+
else:
|
127 |
+
print("Tidak ditemukan elemen meta dengan name twitter:title")
|
128 |
+
return '', ''
|
129 |
+
|
130 |
def format_info(info):
|
131 |
+
response = requests.get(info)
|
132 |
+
soup = BeautifulSoup(response.text, 'html.parser')
|
133 |
+
if 'www.sakurajav.com':
|
134 |
+
actress, series = get_video_info(info)
|
135 |
+
# Mencari thumbnailUrl di elemen meta dengan name="twitter:image"
|
136 |
+
thumbnail = soup.find("meta", attrs={"name": "twitter:image"})
|
137 |
+
if thumbnail:
|
138 |
+
thumbnail_url = thumbnail['content']
|
139 |
+
digit = get_digits(thumbnail_url)
|
140 |
+
info = f"{series} {digit} - {actress}"
|
141 |
+
else:
|
142 |
+
# Menghapus angka '3D' dari awal string dan mengambil 10 karakter terakhir
|
143 |
+
info = info.split('%')[-10].replace('3D1', '').replace('3D', '')
|
144 |
+
|
145 |
+
# Pola regex untuk mencocokkan pola yang dijelaskan
|
146 |
+
pattern = r'([a-z]+)(\d+)'
|
147 |
+
|
148 |
+
# Mencari kecocokan dengan pola regex
|
149 |
+
matches = re.findall(pattern, info, re.IGNORECASE)
|
150 |
+
|
151 |
+
if matches:
|
152 |
+
alfabet, number = matches[0]
|
153 |
+
# Mengubah alfabet menjadi huruf besar dan menghapus '0' dari awal nomor
|
154 |
+
number = number.lstrip('0')
|
155 |
+
# Jika panjang nomor kurang dari 3, tambahkan '0' di depan
|
156 |
+
if len(number) < 3:
|
157 |
+
number = '0' + number
|
158 |
+
info = f"{alfabet.upper()}-{number}"
|
159 |
|
160 |
return info
|