Skip to content

Commit

Permalink
fix bug path
Browse files Browse the repository at this point in the history
  • Loading branch information
Lovi-0 committed Jan 4, 2024
1 parent b96afc9 commit 38be06a
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 217 deletions.
7 changes: 5 additions & 2 deletions Stream/api/film.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Class import
from Stream.util.headers import get_headers
from Stream.util.console import console
from Stream.util.m3u8 import dw_m3u8
from Stream.util.util import convert_utf8_name

# General import
import requests, sys, re, json
Expand Down Expand Up @@ -43,9 +43,12 @@ def get_m3u8_key(json_win_video, json_win_param, title_name):

def main_dw_film(id_film, title_name, domain):

lower_title_name = str(title_name).lower()
title_name = convert_utf8_name(lower_title_name) # ERROR LATIN 1 IN REQ WITH ò à ù ...

embed_content = get_iframe(id_film, domain)
json_win_video, json_win_param = parse_content(embed_content)
m3u8_url = get_m3u8_url(json_win_video, json_win_param)
m3u8_key = get_m3u8_key(json_win_video, json_win_param, title_name)

dw_m3u8(m3u8_url, requests.get(m3u8_url, headers={"User-agent": get_headers()}).text, "", m3u8_key, str(title_name).replace("+", " ").replace(",", "") + ".mp4")
dw_m3u8(m3u8_url, requests.get(m3u8_url, headers={"User-agent": get_headers()}).text, "", m3u8_key, lower_title_name.replace("+", " ").replace(",", "") + ".mp4")
1 change: 0 additions & 1 deletion Stream/api/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def get_version(domain):
return json.loads(info_data_page)['version']

except:

console.log("[red]UPDATE DOMANIN")
sys.exit(0)

Expand Down
32 changes: 20 additions & 12 deletions Stream/api/tv.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

# Class import
from Stream.util.headers import get_headers
from Stream.util.console import console, msg, console_print
from Stream.util.console import console, msg
from Stream.util.m3u8 import dw_m3u8, join_audio_to_video
from Stream.util.util import convert_utf8_name, check_audio_presence

# General import
import requests, os, re, json
Expand Down Expand Up @@ -80,27 +81,34 @@ def main_dw_tv(tv_id, tv_name, version, domain):

token = get_token(tv_id, domain)

tv_name = str(tv_name.replace('+', '-')).lower()
console.log(f"[blue]Season find: [red]{get_info_tv(tv_id, tv_name, version, domain)}")
season_select = msg.ask("[green]Insert season number: ")
lower_tv_name = str(tv_name).lower()
tv_name = convert_utf8_name(lower_tv_name) # ERROR LATIN 1 IN REQ WITH ò à ù ...
console.print(f"[blue]Season find: [red]{get_info_tv(tv_id, tv_name, version, domain)}")
season_select = msg.ask("\n[green]Insert season number: ")

eps = get_info_season(tv_id, tv_name, domain, version, token, season_select)
for ep in eps:
console_print(f"[green]Ep: [blue]{ep['n']} [green]=> [purple]{ep['name']}")
index_ep_select = int(msg.ask("[green]Insert ep number: ")) - 1
console.print(f"[green]Ep: [blue]{ep['n']} [green]=> [purple]{ep['name']}")
index_ep_select = int(msg.ask("\n[green]Insert ep number: ")) - 1

embed_content = get_iframe(tv_id, eps[index_ep_select]['id'], domain, token)
json_win_video, json_win_param = parse_content(embed_content)
m3u8_url = get_m3u8_url(json_win_video, json_win_param)
m3u8_key = get_m3u8_key_ep(json_win_video, json_win_param, tv_name, season_select, index_ep_select+1, eps[index_ep_select]['name'])

dw_m3u8(m3u8_url, requests.get(m3u8_url, headers={"User-agent": get_headers()}).text, "", m3u8_key, tv_name.replace("+", "_") + "_"+str(season_select)+"__"+str(index_ep_select+1) + ".mp4")
mp4_name = lower_tv_name.replace("+", "_") + "_"+str(season_select)+"__"+str(index_ep_select+1)
mp4_format = mp4_name + ".mp4"
base_path_mp4 = os.path.join("videos", mp4_format)
base_audio_path = os.path.join("videos", mp4_format + "_audio.mp4")

is_down_audio = msg.ask("[blue]Download audio [red](!!! Only for recent upload, !!! Use all CPU) [blue][y \ n]").strip()
if str(is_down_audio) == "y":
dw_m3u8(m3u8_url, requests.get(m3u8_url, headers={"User-agent": get_headers()}).text, "", m3u8_key, mp4_format)

if not check_audio_presence(base_path_mp4):
console.log("[red]Audio is not present, start download (Use all CPU)")
m3u8_url_audio = get_m3u8_audio(json_win_video, json_win_param, tv_name, season_select, index_ep_select+1, eps[index_ep_select]['name'])
dw_m3u8(m3u8_url_audio, requests.get(m3u8_url_audio, headers={"User-agent": get_headers()}).text, "", m3u8_key, "audio.mp4")

join_audio_to_video("videos//audio.mp4", "videos//" + tv_name.replace("+", "_") + "_"+str(season_select)+"__"+str(index_ep_select+1) + ".mp4", "videos//" + tv_name.replace("+", "_") + "_"+str(season_select)+"__"+str(index_ep_select+1) + "_audio.mp4")
os.remove("videos//audio.mp4")
os.remove("videos//" + tv_name.replace("+", "_") + "_"+str(season_select)+"__"+str(index_ep_select+1) + ".mp4")
temp_audio_path = os.path.join("videos", "audio.mp4")
join_audio_to_video(temp_audio_path, base_path_mp4, base_audio_path)
os.remove(temp_audio_path)
os.remove(base_path_mp4)
2 changes: 1 addition & 1 deletion Stream/upload/__version__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__title__ = 'Streaming_community'
__version__ = 'v0.5.0'
__version__ = 'v0.6.0'
__author__ = 'Ghost6446'
__description__ = 'A command-line program to download film'
__license__ = 'MIT License'
Expand Down
30 changes: 12 additions & 18 deletions Stream/upload/update.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# 26.12.2023

# Class import
from Stream.util.console import console
# 13.09.2023

# General import
from Stream.util.console import console
import os, requests, time

# Variable
github_repo_name = "StreamingCommunity_api"
repo_name = "StreamingCommunity_api"
repo_user = "ghost6446"
main = os.path.abspath(os.path.dirname(__file__))
base = "\\".join(main.split("\\")[:-1])

Expand All @@ -19,24 +18,19 @@ def get_install_version():

def main_update():

json = requests.get(f"https://api.github.com/repos/ghost6446/{github_repo_name}/releases").json()[0]
stargazers_count = requests.get(f"https://api.github.com/repos/ghost6446/{github_repo_name}").json()['stargazers_count']
json = requests.get(f"https://api.github.com/repos/{repo_user}/{repo_name}/releases").json()[0]
stargazers_count = requests.get(f"https://api.github.com/repos/{repo_user}/{repo_name}").json()['stargazers_count']
last_version = json['name']
down_count = json['assets'][0]['download_count']

# Get percentaul star
if down_count > 0 and stargazers_count > 0:
percentual_stars = round(stargazers_count / down_count * 100, 2)
if down_count > 0 and stargazers_count > 0: percentual_stars = round(stargazers_count / down_count * 100, 2)
else: percentual_stars = 0

if get_install_version() != last_version:
console.log(f"[red]A new version is available")

else:
console.log("[red]Everything up to date")
if get_install_version() != last_version: console.print(f"[red]=> A new version is available")
else: console.print("[red]=> Everything up to date")

print("\n")
console.log(f"[red]Only was downloaded [yellow]{down_count} [red]times, but only [yellow]{percentual_stars} [red]of You(!) have starred it. \n\
[cyan]Help the repository grow today, by leaving a [yellow]star [cyan]on it and sharing it to others online!")
time.sleep(5)
console.print(f"[red]{repo_name} was downloaded [yellow]{down_count} [red]times, but only [yellow]{percentual_stars}% [red]of You(!!) have starred it. \n\
[cyan]Help the repository grow today, by leaving a [yellow]star [cyan]and [yellow]sharing [cyan]it to others online!")
time.sleep(2.5)
print("\n")
1 change: 0 additions & 1 deletion Stream/util/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Import
from rich.console import Console
from rich.prompt import Prompt
from rich import print as console_print

# Variable
msg = Prompt()
Expand Down
1 change: 1 addition & 0 deletions Stream/util/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ def get_headers():
software_names = [SoftwareName.CHROME.value]
operating_systems = [OperatingSystem.WINDOWS.value, OperatingSystem.LINUX.value]
user_agent_rotator = UserAgent(software_names=software_names, operating_systems=operating_systems, limit=10)

return user_agent_rotator.get_random_user_agent()
Loading

0 comments on commit 38be06a

Please sign in to comment.