mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-05 02:55:25 +00:00
Bump v3.0.1
This commit is contained in:
parent
33436ec2fe
commit
bd922afde2
@ -58,7 +58,7 @@ def title_search(query: str) -> int:
|
|||||||
# Create soup and find table
|
# Create soup and find table
|
||||||
soup = BeautifulSoup(response.text, "html.parser")
|
soup = BeautifulSoup(response.text, "html.parser")
|
||||||
|
|
||||||
for tr in soup.find_all('tr'):
|
for i, tr in enumerate(soup.find_all('tr')):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
title_info = {
|
title_info = {
|
||||||
@ -72,6 +72,9 @@ def title_search(query: str) -> int:
|
|||||||
}
|
}
|
||||||
media_search_manager.add_media(title_info)
|
media_search_manager.add_media(title_info)
|
||||||
|
|
||||||
|
if i == 20:
|
||||||
|
break
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error parsing a film entry: {e}")
|
print(f"Error parsing a film entry: {e}")
|
||||||
|
|
||||||
|
@ -1,71 +0,0 @@
|
|||||||
# 09.06.24
|
|
||||||
|
|
||||||
from urllib.parse import quote_plus
|
|
||||||
|
|
||||||
|
|
||||||
# External library
|
|
||||||
from rich.console import Console
|
|
||||||
from rich.prompt import Prompt
|
|
||||||
|
|
||||||
|
|
||||||
# Internal utilities
|
|
||||||
from StreamingCommunity.Api.Template import get_select_title
|
|
||||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
|
||||||
from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
|
|
||||||
|
|
||||||
|
|
||||||
# Logic class
|
|
||||||
from .site import title_search, media_search_manager, table_show_manager
|
|
||||||
from .film import download_film
|
|
||||||
|
|
||||||
|
|
||||||
# Variable
|
|
||||||
indice = 4
|
|
||||||
_useFor = "film"
|
|
||||||
_priority = 0
|
|
||||||
_engineDownload = "mp4"
|
|
||||||
|
|
||||||
msg = Prompt()
|
|
||||||
console = Console()
|
|
||||||
|
|
||||||
|
|
||||||
def process_search_result(select_title):
|
|
||||||
"""
|
|
||||||
Handles the search result and initiates the download for either a film or series.
|
|
||||||
"""
|
|
||||||
# !!! ADD TYPE DONT WORK FOR SERIE
|
|
||||||
download_film(select_title)
|
|
||||||
|
|
||||||
def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_item: dict = None):
|
|
||||||
"""
|
|
||||||
Main function of the application for search.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
string_to_search (str, optional): String to search for
|
|
||||||
get_onylDatabase (bool, optional): If True, return only the database object
|
|
||||||
direct_item (dict, optional): Direct item to process (bypass search)
|
|
||||||
"""
|
|
||||||
if direct_item:
|
|
||||||
select_title = MediaItem(**direct_item)
|
|
||||||
process_search_result(select_title)
|
|
||||||
return
|
|
||||||
|
|
||||||
if string_to_search is None:
|
|
||||||
string_to_search = msg.ask(f"\n[purple]Insert word to search in [green]{site_constant.SITE_NAME}").strip()
|
|
||||||
|
|
||||||
# Search on database
|
|
||||||
len_database = title_search(quote_plus(string_to_search))
|
|
||||||
|
|
||||||
## If only the database is needed, return the manager
|
|
||||||
if get_onlyDatabase:
|
|
||||||
return media_search_manager
|
|
||||||
|
|
||||||
if len_database > 0:
|
|
||||||
select_title = get_select_title(table_show_manager, media_search_manager)
|
|
||||||
process_search_result(select_title)
|
|
||||||
|
|
||||||
else:
|
|
||||||
|
|
||||||
# If no results are found, ask again
|
|
||||||
console.print(f"\n[red]Nothing matching was found for[white]: [purple]{string_to_search}")
|
|
||||||
search()
|
|
@ -1,62 +0,0 @@
|
|||||||
# 03.07.24
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
# External library
|
|
||||||
from rich.console import Console
|
|
||||||
|
|
||||||
|
|
||||||
# Internal utilities
|
|
||||||
from StreamingCommunity.Util.os import os_manager
|
|
||||||
from StreamingCommunity.Util.message import start_message
|
|
||||||
from StreamingCommunity.Lib.Downloader import HLS_Downloader
|
|
||||||
|
|
||||||
|
|
||||||
# Logic class
|
|
||||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
|
||||||
from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
|
|
||||||
|
|
||||||
|
|
||||||
# Player
|
|
||||||
from StreamingCommunity.Api.Player.maxstream import VideoSource
|
|
||||||
|
|
||||||
|
|
||||||
# Variable
|
|
||||||
console = Console()
|
|
||||||
|
|
||||||
|
|
||||||
def download_film(select_title: MediaItem) -> str:
|
|
||||||
"""
|
|
||||||
Downloads a film using the provided obj.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
- select_title (MediaItem): The media item to be downloaded. This should be an instance of the MediaItem class, containing attributes like `name` and `url`.
|
|
||||||
|
|
||||||
Return:
|
|
||||||
- str: output path
|
|
||||||
"""
|
|
||||||
start_message()
|
|
||||||
console.print(f"[bold yellow]Download:[/bold yellow] [red]{site_constant.SITE_NAME}[/red] → [cyan]{select_title.name}[/cyan] \n")
|
|
||||||
|
|
||||||
# Setup api manger
|
|
||||||
video_source = VideoSource(select_title.url)
|
|
||||||
|
|
||||||
# Define output path
|
|
||||||
title_name = os_manager.get_sanitize_file(select_title.name) +".mp4"
|
|
||||||
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, title_name.replace(".mp4", ""))
|
|
||||||
|
|
||||||
# Get m3u8 master playlist
|
|
||||||
master_playlist = video_source.get_playlist()
|
|
||||||
|
|
||||||
# Download the film using the m3u8 playlist, and output filename
|
|
||||||
r_proc = HLS_Downloader(
|
|
||||||
m3u8_url=master_playlist,
|
|
||||||
output_path=os.path.join(mp4_path, title_name)
|
|
||||||
).start()
|
|
||||||
|
|
||||||
if r_proc['error'] is not None:
|
|
||||||
try: os.remove(r_proc['path'])
|
|
||||||
except: pass
|
|
||||||
|
|
||||||
return r_proc['path']
|
|
@ -1,81 +0,0 @@
|
|||||||
# 03.07.24
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
# External libraries
|
|
||||||
import httpx
|
|
||||||
from bs4 import BeautifulSoup
|
|
||||||
from rich.console import Console
|
|
||||||
|
|
||||||
|
|
||||||
# Internal utilities
|
|
||||||
from StreamingCommunity.Util.config_json import config_manager
|
|
||||||
from StreamingCommunity.Util.headers import get_userAgent
|
|
||||||
from StreamingCommunity.Util.table import TVShowManager
|
|
||||||
|
|
||||||
|
|
||||||
# Logic class
|
|
||||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
|
||||||
from StreamingCommunity.Api.Template.Class.SearchType import MediaManager
|
|
||||||
|
|
||||||
|
|
||||||
# Variable
|
|
||||||
console = Console()
|
|
||||||
media_search_manager = MediaManager()
|
|
||||||
table_show_manager = TVShowManager()
|
|
||||||
max_timeout = config_manager.get_int("REQUESTS", "timeout")
|
|
||||||
|
|
||||||
|
|
||||||
def title_search(query: str) -> int:
|
|
||||||
"""
|
|
||||||
Search for titles based on a search query.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
- query (str): The query to search for.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
- int: The number of titles found.
|
|
||||||
"""
|
|
||||||
media_search_manager.clear()
|
|
||||||
table_show_manager.clear()
|
|
||||||
|
|
||||||
search_url = f"{site_constant.FULL_URL}/?s={query}"
|
|
||||||
console.print(f"[cyan]Search url: [yellow]{search_url}")
|
|
||||||
|
|
||||||
try:
|
|
||||||
response = httpx.get(
|
|
||||||
search_url,
|
|
||||||
headers={'user-agent': get_userAgent()},
|
|
||||||
timeout=max_timeout,
|
|
||||||
follow_redirects=True,
|
|
||||||
verify=False
|
|
||||||
)
|
|
||||||
response.raise_for_status()
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
console.print(f"Site: {site_constant.SITE_NAME}, request search error: {e}")
|
|
||||||
return 0
|
|
||||||
|
|
||||||
# Create soup and find table
|
|
||||||
soup = BeautifulSoup(response.text, "html.parser")
|
|
||||||
|
|
||||||
for card in soup.find_all("div", class_=["card", "mp-post", "horizontal"]):
|
|
||||||
try:
|
|
||||||
title_tag = card.find("h3", class_="card-title").find("a")
|
|
||||||
url = title_tag.get("href")
|
|
||||||
title = title_tag.get_text(strip=True)
|
|
||||||
|
|
||||||
title_info = {
|
|
||||||
'name': title,
|
|
||||||
'url': url,
|
|
||||||
'type': 'film'
|
|
||||||
}
|
|
||||||
|
|
||||||
media_search_manager.add_media(title_info)
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Error parsing a film entry: {e}")
|
|
||||||
|
|
||||||
# Return the number of titles found
|
|
||||||
return media_search_manager.get_length()
|
|
@ -1,5 +1,5 @@
|
|||||||
__title__ = 'StreamingCommunity'
|
__title__ = 'StreamingCommunity'
|
||||||
__version__ = '3.0.0'
|
__version__ = '3.0.1'
|
||||||
__author__ = 'Arrowar'
|
__author__ = 'Arrowar'
|
||||||
__description__ = 'A command-line program to download film'
|
__description__ = 'A command-line program to download film'
|
||||||
__copyright__ = 'Copyright 2024'
|
__copyright__ = 'Copyright 2024'
|
||||||
|
@ -12,6 +12,10 @@ from typing import Any, List
|
|||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
|
|
||||||
|
|
||||||
|
# Internal utilities
|
||||||
|
from StreamingCommunity.Util.headers import get_userAgent
|
||||||
|
|
||||||
|
|
||||||
# Variable
|
# Variable
|
||||||
console = Console()
|
console = Console()
|
||||||
download_site_data = True
|
download_site_data = True
|
||||||
@ -134,7 +138,7 @@ class ConfigManager:
|
|||||||
console.print(f"[bold cyan]Downloading reference configuration:[/bold cyan] [green]{self.reference_config_url}[/green]")
|
console.print(f"[bold cyan]Downloading reference configuration:[/bold cyan] [green]{self.reference_config_url}[/green]")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.get(self.reference_config_url, timeout=10)
|
response = requests.get(self.reference_config_url, timeout=8, headers={'User-Agent': get_userAgent()})
|
||||||
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
with open(self.file_path, 'wb') as f:
|
with open(self.file_path, 'wb') as f:
|
||||||
@ -156,7 +160,7 @@ class ConfigManager:
|
|||||||
try:
|
try:
|
||||||
# Download the reference configuration
|
# Download the reference configuration
|
||||||
console.print(f"[bold cyan]Validating configuration with GitHub...[/bold cyan]")
|
console.print(f"[bold cyan]Validating configuration with GitHub...[/bold cyan]")
|
||||||
response = requests.get(self.reference_config_url, timeout=10)
|
response = requests.get(self.reference_config_url, timeout=8, headers={'User-Agent': get_userAgent()})
|
||||||
|
|
||||||
if not response.ok:
|
if not response.ok:
|
||||||
raise Exception(f"Error downloading reference configuration. Code: {response.status_code}")
|
raise Exception(f"Error downloading reference configuration. Code: {response.status_code}")
|
||||||
@ -267,13 +271,14 @@ class ConfigManager:
|
|||||||
headers = {
|
headers = {
|
||||||
"apikey": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inp2Zm5ncG94d3Jnc3duenl0YWRoIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDAxNTIxNjMsImV4cCI6MjA1NTcyODE2M30.FNTCCMwi0QaKjOu8gtZsT5yQttUW8QiDDGXmzkn89QE",
|
"apikey": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inp2Zm5ncG94d3Jnc3duenl0YWRoIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDAxNTIxNjMsImV4cCI6MjA1NTcyODE2M30.FNTCCMwi0QaKjOu8gtZsT5yQttUW8QiDDGXmzkn89QE",
|
||||||
"Authorization": f"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inp2Zm5ncG94d3Jnc3duenl0YWRoIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDAxNTIxNjMsImV4cCI6MjA1NTcyODE2M30.FNTCCMwi0QaKjOu8gtZsT5yQttUW8QiDDGXmzkn89QE",
|
"Authorization": f"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inp2Zm5ncG94d3Jnc3duenl0YWRoIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDAxNTIxNjMsImV4cCI6MjA1NTcyODE2M30.FNTCCMwi0QaKjOu8gtZsT5yQttUW8QiDDGXmzkn89QE",
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json",
|
||||||
|
"User-Agent": get_userAgent()
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
console.print("[bold cyan]Retrieving site data from API...[/bold cyan]")
|
console.print("[bold cyan]Retrieving site data from API...[/bold cyan]")
|
||||||
response = requests.get("https://zvfngpoxwrgswnzytadh.supabase.co/rest/v1/public", headers=headers, timeout=10)
|
response = requests.get("https://zvfngpoxwrgswnzytadh.supabase.co/rest/v1/public", timeout=8, headers=headers)
|
||||||
|
|
||||||
if response.ok:
|
if response.ok:
|
||||||
data = response.json()
|
data = response.json()
|
||||||
if data and len(data) > 0:
|
if data and len(data) > 0:
|
||||||
@ -282,13 +287,6 @@ class ConfigManager:
|
|||||||
site_count = len(self.configSite) if isinstance(self.configSite, dict) else 0
|
site_count = len(self.configSite) if isinstance(self.configSite, dict) else 0
|
||||||
console.print(f"[bold green]Site data retrieved:[/bold green] {site_count} streaming services available")
|
console.print(f"[bold green]Site data retrieved:[/bold green] {site_count} streaming services available")
|
||||||
|
|
||||||
# Show some sites as examples
|
|
||||||
if site_count > 0:
|
|
||||||
examples = list(self.configSite.items())[:3]
|
|
||||||
sites_info = []
|
|
||||||
for site, info in examples:
|
|
||||||
url = info.get('full_url', 'N/A')
|
|
||||||
console.print(f" • [cyan]{site}[/cyan]: {url}")
|
|
||||||
else:
|
else:
|
||||||
console.print("[bold yellow]API returned an empty data set[/bold yellow]")
|
console.print("[bold yellow]API returned an empty data set[/bold yellow]")
|
||||||
else:
|
else:
|
||||||
@ -347,7 +345,7 @@ class ConfigManager:
|
|||||||
try:
|
try:
|
||||||
logging.info(f"Downloading {filename} from {url}...")
|
logging.info(f"Downloading {filename} from {url}...")
|
||||||
console.print(f"[bold cyan]File download:[/bold cyan] {os.path.basename(filename)}")
|
console.print(f"[bold cyan]File download:[/bold cyan] {os.path.basename(filename)}")
|
||||||
response = requests.get(url, timeout=10)
|
response = requests.get(url, timeout=8, headers={'User-Agent': get_userAgent()})
|
||||||
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
with open(filename, 'wb') as f:
|
with open(filename, 'wb') as f:
|
||||||
|
2
setup.py
2
setup.py
@ -10,7 +10,7 @@ with open(os.path.join(os.path.dirname(__file__), "requirements.txt"), "r", enco
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="StreamingCommunity",
|
name="StreamingCommunity",
|
||||||
version="3.0.0",
|
version="3.0.1",
|
||||||
long_description=read_readme(),
|
long_description=read_readme(),
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
author="Lovi-0",
|
author="Lovi-0",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user