Skip to content

Commit

Permalink
Store domain in a JSON file (#46)
Browse files Browse the repository at this point in the history
* Refactor domain function to store domain in a JSON file

* Revert "update version"

This reverts commit f866d9b.
  • Loading branch information
Fede14it authored Feb 28, 2024
1 parent f866d9b commit fec9df9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
34 changes: 19 additions & 15 deletions Src/Api/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,34 @@
from bs4 import BeautifulSoup

def domain_version():

console.print("[green]Get rules ...")
req_repo = requests.get("https://raw.githubusercontent.com/Ghost6446/Streaming_comunity_data/main/data.json", headers={'user-agent': get_headers()}, timeout=5)
domain = req_repo.json()['domain']

if req_repo.ok:
req_repo = None
try:
with open('data.json', 'r') as file:
req_repo = json.load(file)
except FileNotFoundError:
req_repo = {"domain": ""}
domain = req_repo['domain']

while True:
if not domain:
domain = input("Insert domain (streamingcommunity.?): ")
req_repo['domain'] = domain
with open('data.json', 'w') as file:
json.dump(req_repo, file)
console.print(f"[blue]Test domain [white]=> [red]{domain}")
site_url = f"https://streamingcommunity.{domain}"
site_request = requests.get(site_url, headers={'user-agent': get_headers()})

try:
site_request = requests.get(site_url, headers={'user-agent': get_headers()})
soup = BeautifulSoup(site_request.text, "lxml")
version = json.loads(soup.find("div", {"id": "app"}).get("data-page"))['version']
console.print(f"[blue]Rules [white]=> [red].{domain}")

return domain, version

except:
console.log("[red]Cant get version, problem with domain")
sys.exit(0)

else:
console.log(f"[red]Error: {req_repo.status_code}")
sys.exit(0)
except Exception as e:
console.log("[red]Cant get version, problem with domain. Try again.")
domain = None
continue

def search(title_search, domain):

Expand Down
11 changes: 8 additions & 3 deletions Src/Lib/FFmpeg/my_m3u8.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,12 @@ def get_req_ts(self, ts_url):
"""Single req to a ts file to get content"""

url_number = self.segments.index(ts_url)
is_valid = ( str(url_number) in failed_segments )

is_valid = True
for failde_seg in failed_segments:
if str(failde_seg) in ts_url:
is_valid = False
break

if is_valid:

Expand Down Expand Up @@ -307,8 +312,8 @@ def extract_number(file_name):

with open(file_list_path, 'w') as f:
for ts_file in ts_files:
absolute_path = os.path.abspath(os.path.join(self.temp_folder, ts_file), current_dir)
f.write(f"file '{absolute_path}'\n")
relative_path = os.path.relpath(os.path.join(self.temp_folder, ts_file), current_dir)
f.write(f"file '{relative_path}'\n")

console.log("[cyan]Start join all file")
try:
Expand Down
2 changes: 1 addition & 1 deletion Src/Upload/__version__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__title__ = 'Streaming_community'
__version__ = 'v0.8.6'
__version__ = 'v0.8.5'
__author__ = 'Ghost6446'
__description__ = 'A command-line program to download film'
__license__ = 'MIT License'
Expand Down
1 change: 1 addition & 0 deletions data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"domain": "express"}

0 comments on commit fec9df9

Please sign in to comment.