Spaces:
Building
Building
GilangAlRusliadi
commited on
Commit
•
4e350f0
1
Parent(s):
569fdf5
- Torrent.py +0 -61
- app.py +2 -1
- others.py +86 -0
Torrent.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import libtorrent as lt
|
2 |
import streamlit as st
|
3 |
import os
|
4 |
-
import re
|
5 |
import time
|
6 |
import requests
|
7 |
|
@@ -19,25 +18,6 @@ if not os.path.exists(download_folder):
|
|
19 |
else:
|
20 |
print("Folder 'Hasil Download' sudah ada")
|
21 |
|
22 |
-
def sesi(info, lokasi_file):
|
23 |
-
st.session_state.info = info
|
24 |
-
st.session_state.lokasi_file = lokasi_file
|
25 |
-
|
26 |
-
if 'info' in st.session_state:
|
27 |
-
num_lines = st.session_state.info.count('\n') + 1
|
28 |
-
text_area_height = 25 * num_lines
|
29 |
-
st.text_area("Hasil Redirect", st.session_state.info, height=text_area_height)
|
30 |
-
with open(st.session_state.lokasi_file, 'rb') as f:
|
31 |
-
file_contents = f.read()
|
32 |
-
st.download_button(
|
33 |
-
label="Download File TXT",
|
34 |
-
data=file_contents,
|
35 |
-
file_name=st.session_state.lokasi_file.replace('/home/user/app/', '').title().replace('Txt', 'txt'),
|
36 |
-
mime='text/plain'
|
37 |
-
)
|
38 |
-
|
39 |
-
return st.session_state.info, st.session_state.lokasi_file
|
40 |
-
|
41 |
def torrent_info(link, search, ext):
|
42 |
params = {
|
43 |
'save_path': download_folder,
|
@@ -132,44 +112,3 @@ def torrent_group(x, input):
|
|
132 |
info += f"Kelompok {i+1}: {result}\n"
|
133 |
|
134 |
return info
|
135 |
-
|
136 |
-
def simpan_txt(nama_file, teks):
|
137 |
-
with open(nama_file + '.txt', 'w') as f:
|
138 |
-
f.write(teks)
|
139 |
-
lokasi_file = os.path.abspath(nama_file + '.txt')
|
140 |
-
return lokasi_file
|
141 |
-
|
142 |
-
def link_redirect(url):
|
143 |
-
info = ''
|
144 |
-
response = requests.get(url)
|
145 |
-
if response.history:
|
146 |
-
info += f"Redirects: \n"
|
147 |
-
for resp in response.history:
|
148 |
-
info += f"{response.status_code} {response.url}\n\n"
|
149 |
-
info += f"Final destination: \n"
|
150 |
-
info += f"{response.status_code} {response.url}\n"
|
151 |
-
else:
|
152 |
-
info += f"No Redirects: \n"
|
153 |
-
|
154 |
-
return info
|
155 |
-
|
156 |
-
def format_info(info):
|
157 |
-
# Menghapus angka '3D' dari awal string dan mengambil 10 karakter terakhir
|
158 |
-
info = info.split('%')[-10].replace('3D1', '').replace('3D', '')
|
159 |
-
|
160 |
-
# Pola regex untuk mencocokkan pola yang dijelaskan
|
161 |
-
pattern = r'([a-z]+)(\d+)'
|
162 |
-
|
163 |
-
# Mencari kecocokan dengan pola regex
|
164 |
-
matches = re.findall(pattern, info, re.IGNORECASE)
|
165 |
-
|
166 |
-
if matches:
|
167 |
-
alfabet, number = matches[0]
|
168 |
-
# Mengubah alfabet menjadi huruf besar dan menghapus '0' dari awal nomor
|
169 |
-
number = number.lstrip('0')
|
170 |
-
# Jika panjang nomor kurang dari 3, tambahkan '0' di depan
|
171 |
-
if len(number) < 3:
|
172 |
-
number = '0' + number
|
173 |
-
info = f"{alfabet.upper()}-{number}"
|
174 |
-
|
175 |
-
return info
|
|
|
1 |
import libtorrent as lt
|
2 |
import streamlit as st
|
3 |
import os
|
|
|
4 |
import time
|
5 |
import requests
|
6 |
|
|
|
18 |
else:
|
19 |
print("Folder 'Hasil Download' sudah ada")
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
def torrent_info(link, search, ext):
|
22 |
params = {
|
23 |
'save_path': download_folder,
|
|
|
112 |
info += f"Kelompok {i+1}: {result}\n"
|
113 |
|
114 |
return info
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
@@ -9,7 +9,8 @@ import re
|
|
9 |
|
10 |
import streamlit as st
|
11 |
from streamlit_option_menu import option_menu
|
12 |
-
from
|
|
|
13 |
|
14 |
option = ['Magnet Link', 'Index Torrent', 'Link Redirect', 'Kode']
|
15 |
# Navigasi Sidebar
|
|
|
9 |
|
10 |
import streamlit as st
|
11 |
from streamlit_option_menu import option_menu
|
12 |
+
from others import *
|
13 |
+
from torrent import *
|
14 |
|
15 |
option = ['Magnet Link', 'Index Torrent', 'Link Redirect', 'Kode']
|
16 |
# Navigasi Sidebar
|
others.py
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import libtorrent as lt
|
2 |
+
import streamlit as st
|
3 |
+
import os
|
4 |
+
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
|
11 |
+
|
12 |
+
if 'info' in st.session_state:
|
13 |
+
num_lines = st.session_state.info.count('\n') + 1
|
14 |
+
text_area_height = 25 * num_lines
|
15 |
+
st.text_area("Hasil Redirect", st.session_state.info, height=text_area_height)
|
16 |
+
with open(st.session_state.lokasi_file, 'rb') as f:
|
17 |
+
file_contents = f.read()
|
18 |
+
st.download_button(
|
19 |
+
label="Download File TXT",
|
20 |
+
data=file_contents,
|
21 |
+
file_name=st.session_state.lokasi_file.replace('/home/user/app/', '').title().replace('Txt', 'txt'),
|
22 |
+
mime='text/plain'
|
23 |
+
)
|
24 |
+
|
25 |
+
return st.session_state.info, st.session_state.lokasi_file
|
26 |
+
|
27 |
+
def simpan_txt(nama_file, teks):
|
28 |
+
with open(nama_file + '.txt', 'w') as f:
|
29 |
+
f.write(teks)
|
30 |
+
lokasi_file = os.path.abspath(nama_file + '.txt')
|
31 |
+
return lokasi_file
|
32 |
+
|
33 |
+
def link_redirect(url):
|
34 |
+
# Kamus untuk menerjemahkan kode status
|
35 |
+
status_codes = {
|
36 |
+
200: 'OK',
|
37 |
+
301: 'Dipindahkan Secara Permanen',
|
38 |
+
302: 'Ditemukan',
|
39 |
+
303: 'Lihat Lainnya',
|
40 |
+
304: 'Tidak Dimodifikasi',
|
41 |
+
307: 'Pengalihan Sementara',
|
42 |
+
400: 'Permintaan Buruk',
|
43 |
+
401: 'Tidak Sah',
|
44 |
+
403: 'Dilarang',
|
45 |
+
404: 'Tidak Ditemukan',
|
46 |
+
500: 'Kesalahan Server Internal',
|
47 |
+
502: 'Gerbang Buruk',
|
48 |
+
503: 'Layanan Tidak Tersedia'
|
49 |
+
}
|
50 |
+
|
51 |
+
info = ''
|
52 |
+
response = requests.get(url)
|
53 |
+
if response.history:
|
54 |
+
info += "Redirects: \n"
|
55 |
+
for resp in response.history:
|
56 |
+
status = status_codes.get(resp.status_code, 'Kode Status Tidak Diketahui')
|
57 |
+
info += f"[{resp.status_code} {status}] \n {resp.url}\n\n"
|
58 |
+
info += "Final destination: \n"
|
59 |
+
status = status_codes.get(response.status_code, 'Kode Status Tidak Diketahui')
|
60 |
+
info += f"[{response.status_code} {status}] \n {response.url}\n"
|
61 |
+
else:
|
62 |
+
info += "No Redirects: \n"
|
63 |
+
|
64 |
+
return info
|
65 |
+
|
66 |
+
|
67 |
+
def format_info(info):
|
68 |
+
# Menghapus angka '3D' dari awal string dan mengambil 10 karakter terakhir
|
69 |
+
info = info.split('%')[-10].replace('3D1', '').replace('3D', '')
|
70 |
+
|
71 |
+
# Pola regex untuk mencocokkan pola yang dijelaskan
|
72 |
+
pattern = r'([a-z]+)(\d+)'
|
73 |
+
|
74 |
+
# Mencari kecocokan dengan pola regex
|
75 |
+
matches = re.findall(pattern, info, re.IGNORECASE)
|
76 |
+
|
77 |
+
if matches:
|
78 |
+
alfabet, number = matches[0]
|
79 |
+
# Mengubah alfabet menjadi huruf besar dan menghapus '0' dari awal nomor
|
80 |
+
number = number.lstrip('0')
|
81 |
+
# Jika panjang nomor kurang dari 3, tambahkan '0' di depan
|
82 |
+
if len(number) < 3:
|
83 |
+
number = '0' + number
|
84 |
+
info = f"{alfabet.upper()}-{number}"
|
85 |
+
|
86 |
+
return info
|