Bump v2.9.6

This commit is contained in:
Lovi 2025-03-22 11:49:40 +01:00
parent d0bdd8c6a3
commit e864855dd5
24 changed files with 98 additions and 93 deletions

View File

@ -26,12 +26,12 @@ table_show_manager = TVShowManager()
max_timeout = config_manager.get_int("REQUESTS", "timeout")
def title_search(word_to_search: str) -> int:
def title_search(query: str) -> int:
"""
Search for titles based on a search query.
Parameters:
- title_search (str): The title to search for.
- query (str): The query to search for.
Returns:
- int: The number of titles found.
@ -39,7 +39,7 @@ def title_search(word_to_search: str) -> int:
media_search_manager.clear()
table_show_manager.clear()
search_url = f"{site_constant.FULL_URL}/search/{word_to_search}/1/"
search_url = f"{site_constant.FULL_URL}/search/{query}/1/"
console.print(f"[cyan]Search url: [yellow]{search_url}")
try:

View File

@ -33,9 +33,8 @@ def download_title(select_title: MediaItem):
- select_title (MediaItem): The media item to be downloaded. This should be an instance of the MediaItem class, containing attributes like `name` and `url`.
"""
start_message()
console.print(f"[yellow]Download: [red]{select_title.name} \n")
print()
console.print(f"[bold yellow]Download:[/bold yellow] [red]{site_constant.SITE_NAME}[/red] → [cyan]{select_title.name}[/cyan] \n")
# Define output path
title_name = os_manager.get_sanitize_file(select_title.name)
mp4_path = os.path.join(site_constant.MOVIE_FOLDER, title_name.replace(".mp4", ""))

View File

@ -56,7 +56,7 @@ def download_film(select_title: MediaItem) -> str:
TelegramSession.updateScriptId(script_id, select_title.name)
start_message()
console.print(f"[yellow]Download: [red]{select_title.name} \n")
console.print(f"[bold yellow]Download:[/bold yellow] [red]{site_constant.SITE_NAME}[/red] → [cyan]{select_title.name}[/cyan] \n")
# Extract mostraguarda link
try:

View File

@ -55,8 +55,7 @@ def download_video(index_season_selected: int, index_episode_selected: int, scra
# Get info about episode
obj_episode = scrape_serie.seasons_manager.get_season_by_number(int(index_season_selected)).episodes.get(index_episode_selected-1)
console.print(f"[yellow]Download: [red]{index_season_selected}:{index_episode_selected} {obj_episode.name}")
print()
console.print(f"[bold yellow]Download:[/bold yellow] [red]{site_constant.SITE_NAME}[/red] → [bold magenta]{obj_episode.name}[/bold magenta] ([cyan]S{index_season_selected}E{index_episode_selected}[/cyan]) \n")
if site_constant.TELEGRAM_BOT:
bot = get_bot_instance()

View File

@ -26,12 +26,12 @@ table_show_manager = TVShowManager()
max_timeout = config_manager.get_int("REQUESTS", "timeout")
def title_search(title_search: str) -> int:
def title_search(query: str) -> int:
"""
Search for titles based on a search query.
Parameters:
- title_search (str): The title to search for.
- query (str): The query to search for.
Returns:
int: The number of titles found.
@ -42,7 +42,7 @@ def title_search(title_search: str) -> int:
media_search_manager.clear()
table_show_manager.clear()
search_url = f"{site_constant.FULL_URL}/?story={title_search}&do=search&subaction=search"
search_url = f"{site_constant.FULL_URL}/?story={query}&do=search&subaction=search"
console.print(f"[cyan]Search url: [yellow]{search_url}")
try:

View File

@ -55,8 +55,7 @@ def download_episode(index_select: int, scrape_serie: ScrapeSerieAnime, video_so
if obj_episode is not None:
start_message()
console.print(f"[yellow]Download: [red]EP_{obj_episode.number} \n")
console.print("[cyan]You can safely stop the download with [bold]Ctrl+c[bold] [cyan] \n")
console.print(f"[bold yellow]Download:[/bold yellow] [red]{site_constant.SITE_NAME}[/red] ([cyan]E{obj_episode.number}[/cyan]) \n")
if site_constant.TELEGRAM_BOT:
bot.send_message(f"Download in corso:\nTitolo:{scrape_serie.series_name}\nEpisodio: {obj_episode.number}", None)
@ -70,7 +69,7 @@ def download_episode(index_select: int, scrape_serie: ScrapeSerieAnime, video_so
video_source.get_embed(obj_episode.id)
# Create output path
title_name = f"{scrape_serie.series_name}_EP_{dynamic_format_number(str(obj_episode.number))}.mp4"
mp4_name = f"{scrape_serie.series_name}_EP_{dynamic_format_number(str(obj_episode.number))}.mp4"
if scrape_serie.is_series:
mp4_path = os_manager.get_sanitize_path(os.path.join(site_constant.ANIME_FOLDER, scrape_serie.series_name))
@ -84,7 +83,7 @@ def download_episode(index_select: int, scrape_serie: ScrapeSerieAnime, video_so
# Start downloading
path, kill_handler = MP4_downloader(
url=str(video_source.src_mp4).strip(),
path=os.path.join(mp4_path, title_name)
path=os.path.join(mp4_path, mp4_name)
)
return path, kill_handler

View File

@ -83,12 +83,12 @@ def get_real_title(record):
return record['title_it']
def title_search(title: str) -> int:
def title_search(query: str) -> int:
"""
Function to perform an anime search using a provided title.
Function to perform an anime search using a provided query.
Parameters:
- title_search (str): The title to search for.
- query (str): The query to search for.
Returns:
- int: A number containing the length of media search manager.
@ -106,7 +106,7 @@ def title_search(title: str) -> int:
'user-agent': get_userAgent(),
'x-csrf-token': data.get('csrf_token')
}
json_data = {'title': title}
json_data = {'title': query}
# Send a POST request to the API endpoint for live search
try:

View File

@ -19,7 +19,7 @@ from .serie import download_series
# Variable
indice = 8
_useFor = "anime"
_deprecate = True
_deprecate = False
_priority = 2
_engineDownload = "mp4"

View File

@ -19,7 +19,7 @@ from StreamingCommunity.Lib.Downloader import MP4_downloader
# Logic class
from .util.ScrapeSerie import ScrapSerie
from StreamingCommunity.Api.Template.config_loader import site_constant
from StreamingCommunity.Api.Template.Util import manage_selection, dynamic_format_number
from StreamingCommunity.Api.Template.Util import manage_selection, dynamic_format_number, map_episode_title
from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
@ -48,12 +48,11 @@ def download_episode(index_select: int, scrape_serie: ScrapSerie, episodes) -> T
start_message()
# Get information about the selected episode
console.print(f"[yellow]Download: [red]EP_{index_select} \n")
console.print("[cyan]You can safely stop the download with [bold]Ctrl+c[bold] [cyan] \n")
console.print(f"[bold yellow]Download:[/bold yellow] [red]{site_constant.SITE_NAME}[/red] ([cyan]E{index_select+1}[/cyan]) \n")
# Create output path
title_name = f"{scrape_serie.get_name()}_EP_{dynamic_format_number(str(index_select))}.mp4"
mp4_path = os_manager.get_sanitize_path(os.path.join(site_constant.ANIME_FOLDER, scrape_serie.get_name()))
# Define filename and path for the downloaded video
mp4_name = f"{scrape_serie.get_name()}_EP_{dynamic_format_number(str(index_select+1))}.mp4"
mp4_path = os.path.join(site_constant.ANIME_FOLDER, scrape_serie.get_name())
# Create output folder
os_manager.create_path(mp4_path)
@ -65,7 +64,7 @@ def download_episode(index_select: int, scrape_serie: ScrapSerie, episodes) -> T
# Start downloading
path, kill_handler = MP4_downloader(
url=str(mp4_link).strip(),
path=os.path.join(mp4_path, title_name)
path=os.path.join(mp4_path, mp4_name)
)
return path, kill_handler

View File

@ -55,45 +55,54 @@ def get_session_and_csrf() -> dict:
logging.info(f"CSRF Token: {csrf_token}")
return session_id, csrf_token
def title_search(title: str) -> int:
def title_search(query: str) -> int:
"""
Function to perform an anime search using a provided title.
Parameters:
- title_search (str): The title to search for.
- query (str): The query to search for.
Returns:
- int: A number containing the length of media search manager.
"""
session_id, csrf_token = get_session_and_csrf()
url = f"{site_constant.FULL_URL}/api/search/v2"
search_url = f"{site_constant.FULL_URL}/search?keyword={query}"
console.print(f"[cyan]Search url: [yellow]{search_url}")
# Set up the headers, params for the request
headers = {
'User-Agent': get_userAgent(),
'Accept': 'application/json, text/javascript, */*; q=0.01',
'CSRF-Token': csrf_token,
'X-Requested-With': 'XMLHttpRequest'
}
params = {
'keyword': title,
}
# Make the GET request
try:
response = httpx.get(search_url, headers={'User-Agent': get_userAgent()})
# Make the POST request
response = httpx.post(url, params=params, cookies={'sessionId': session_id}, headers=headers)
for dict_title in response.json()['animes']:
except Exception as e:
console.print(f"Site: {site_constant.SITE_NAME}, request search error: {e}")
return 0
# Create soup istance
soup = BeautifulSoup(response.text, 'html.parser')
# Collect data from soup
for element in soup.find_all('a', class_='poster'):
try:
title = element.find('img').get('alt')
url = f"{site_constant.FULL_URL}{element.get('href')}"
status_div = element.find('div', class_='status')
is_dubbed = False
anime_type = 'TV'
media_search_manager.add_media({
'id': dict_title.get('id'),
'name': dict_title.get('name'),
'type': 'TV',
'status': dict_title.get('stateName'),
'episodes_count': dict_title.get('episodes'),
'plot': ' '.join((words := str(dict_title.get('story', '')).split())[:10]) + ('...' if len(words) > 10 else ''),
'url': f"{site_constant.FULL_URL}/play/{dict_title.get('link')}.{dict_title.get('identifier')}"
})
if status_div:
if status_div.find('div', class_='dub'):
is_dubbed = True
if status_div.find('div', class_='movie'):
anime_type = 'Movie'
elif status_div.find('div', class_='ona'):
anime_type = 'ONA'
media_search_manager.add_media({
'name': title,
'type': anime_type,
'DUB': is_dubbed,
'url': url
})
except Exception as e:
print(f"Error parsing a film entry: {e}")

View File

@ -5,9 +5,11 @@
import httpx
from bs4 import BeautifulSoup
# Internal utilities
from StreamingCommunity.Util.headers import get_userAgent
from StreamingCommunity.Util.config_json import config_manager
from StreamingCommunity.Util.os import os_manager
# Player
@ -19,7 +21,6 @@ from StreamingCommunity.Api.Player.sweetpixel import AnimeWorldPlayer
max_timeout = config_manager.get_int("REQUESTS", "timeout")
class ScrapSerie:
def __init__(self, url, full_url):
"""Initialize the ScrapSerie object with the provided URL and setup the HTTP client."""
@ -32,22 +33,22 @@ class ScrapSerie:
base_url=full_url
)
try:
self.response = self.client.get(self.link, timeout=max_timeout, follow_redirects=True)
self.response.raise_for_status()
except:
raise Exception(f"Failed to retrieve anime page.")
def get_name(self):
"""Extract and return the name of the anime series."""
response = self.client.get(self.link, follow_redirects=True)
if response.status_code == 200:
soup = BeautifulSoup(response.content, "html.parser")
return soup.find("h1", {"id": "anime-title"}).get_text()
else:
raise Exception(f"Failed to retrieve anime name. Status code: {response.status_code}")
soup = BeautifulSoup(self.response.content, "html.parser")
return os_manager.get_sanitize_file(soup.find("h1", {"id": "anime-title"}).get_text(strip=True))
def get_episodes(self, nums=None):
"""Fetch and return the list of episodes, optionally filtering by specific episode numbers."""
response = self.client.get(self.link, follow_redirects=True)
if response.status_code != 200:
raise Exception(f"Failed to retrieve episodes. Status code: {response.status_code}")
soup = BeautifulSoup(response.content.decode('utf-8', 'ignore'), "html.parser")
soup = BeautifulSoup(self.response.content, "html.parser")
raw_eps = {}
for data in soup.select('li.episode > a'):
@ -75,4 +76,4 @@ class ScrapSerie:
return AnimeWorldPlayer(episode_data, self.session_id, self.csrf_token)
else:
raise IndexError("Episode index out of range")
raise IndexError("Episode index out of range")

View File

@ -37,7 +37,7 @@ def download_film(select_title: MediaItem) -> str:
- str: output path
"""
start_message()
console.print(f"[yellow]Download: [red]{select_title.name} \n")
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)

View File

@ -27,12 +27,12 @@ table_show_manager = TVShowManager()
max_timeout = config_manager.get_int("REQUESTS", "timeout")
def title_search(word_to_search: str) -> int:
def title_search(query: str) -> int:
"""
Search for titles based on a search query.
Parameters:
- title_search (str): The title to search for.
- query (str): The query to search for.
Returns:
- int: The number of titles found.
@ -40,7 +40,7 @@ def title_search(word_to_search: str) -> int:
media_search_manager.clear()
table_show_manager.clear()
search_url = f"{site_constant.FULL_URL}/?s={word_to_search}"
search_url = f"{site_constant.FULL_URL}/?s={query}"
console.print(f"[cyan]Search url: [yellow]{search_url}")
try:

View File

@ -51,8 +51,8 @@ def download_video(index_episode_selected: int, scape_info_serie: GetSerieInfo,
# Get info about episode
obj_episode = scape_info_serie.list_episodes[index_episode_selected - 1]
console.print(f"[yellow]Download: [red]{obj_episode.get('name')}\n")
console.print(f"[bold yellow]Download:[/bold yellow] [red]{site_constant.SITE_NAME}[/red] → [bold magenta]{obj_episode.get('name')}[/bold magenta] ([cyan]E{index_episode_selected}[/cyan]) \n")
# Define filename and path for the downloaded video
title_name = os_manager.get_sanitize_file(
f"{map_episode_title(scape_info_serie.tv_name, None, index_episode_selected, obj_episode.get('name'))}.mp4"

View File

@ -28,12 +28,12 @@ table_show_manager = TVShowManager()
max_timeout = config_manager.get_int("REQUESTS", "timeout")
def title_search(word_to_search: str) -> int:
def title_search(query: str) -> int:
"""
Search for titles based on a search query.
Parameters:
- title_search (str): The title to search for.
- query (str): The query to search for.
Returns:
- int: The number of titles found.
@ -41,7 +41,7 @@ def title_search(word_to_search: str) -> int:
media_search_manager.clear()
table_show_manager.clear()
search_url = f"{site_constant.FULL_URL}/search/?&q={word_to_search}&quick=1&type=videobox_video&nodes=11"
search_url = f"{site_constant.FULL_URL}/search/?&q={query}&quick=1&type=videobox_video&nodes=11"
console.print(f"[cyan]Search url: [yellow]{search_url}")
try:

View File

@ -55,7 +55,7 @@ def download_video(index_season_selected: int, index_episode_selected: int, scap
# Get info about episode
obj_episode = scape_info_serie.list_episodes[index_episode_selected - 1]
console.print(f"[yellow]Download: [red]{index_season_selected}:{index_episode_selected} {obj_episode.get('name')}\n")
console.print(f"[bold yellow]Download:[/bold yellow] [red]{site_constant.SITE_NAME}[/red] → [bold magenta]{obj_episode.get('name')}[/bold magenta] ([cyan]S{index_season_selected}E{index_episode_selected}[/cyan]) \n")
# Define filename and path for the downloaded video
mp4_name = f"{map_episode_title(scape_info_serie.tv_name, index_season_selected, index_episode_selected, obj_episode.get('name'))}.mp4"

View File

@ -27,12 +27,12 @@ max_timeout = config_manager.get_int("REQUESTS", "timeout")
def title_search(word_to_search: str) -> int:
def title_search(query: str) -> int:
"""
Search for titles based on a search query.
Parameters:
- title_search (str): The title to search for.
- query (str): The query to search for.
Returns:
- int: The number of titles found.
@ -40,7 +40,7 @@ def title_search(word_to_search: str) -> int:
media_search_manager.clear()
table_show_manager.clear()
search_url = f"{site_constant.FULL_URL}/?story={word_to_search}&do=search&subaction=search"
search_url = f"{site_constant.FULL_URL}/?story={query}&do=search&subaction=search"
console.print(f"[cyan]Search url: [yellow]{search_url}")
try:

View File

@ -44,7 +44,7 @@ def download_film(movie_details: Json_film) -> str:
# Start message and display film information
start_message()
console.print(f"[yellow]Download: [red]{movie_details.title} \n")
console.print(f"[bold yellow]Download:[/bold yellow] [red]{site_constant.SITE_NAME}[/red] → [cyan]{movie_details.title}[/cyan] \n")
# Make request to main site
try:

View File

@ -52,7 +52,7 @@ def download_film(select_title: MediaItem) -> str:
# Start message and display film information
start_message()
console.print(f"[yellow]Download: [red]{select_title.name} \n")
console.print(f"[bold yellow]Download:[/bold yellow] [red]{site_constant.SITE_NAME}[/red] → [cyan]{select_title.name}[/cyan] \n")
# Init class
video_source = VideoSource(site_constant.FULL_URL, False)

View File

@ -61,8 +61,7 @@ def download_video(index_season_selected: int, index_episode_selected: int, scra
# Get info about episode
obj_episode = season.episodes.get(index_episode_selected - 1)
console.print(f"[yellow]Download: [red]{index_season_selected}:{index_episode_selected} {obj_episode.name}")
print()
console.print(f"[bold yellow]Download:[/bold yellow] [red]{site_constant.SITE_NAME}[/red] → [bold magenta]{obj_episode.name}[/bold magenta] ([cyan]S{index_season_selected}E{index_episode_selected}[/cyan]) \n")
if site_constant.TELEGRAM_BOT:
bot = get_bot_instance()

View File

@ -27,12 +27,12 @@ table_show_manager = TVShowManager()
max_timeout = config_manager.get_int("REQUESTS", "timeout")
def title_search(title_search: str) -> int:
def title_search(query: str) -> int:
"""
Search for titles based on a search query.
Parameters:
- title_search (str): The title to search for.
- query (str): The query to search for.
Returns:
int: The number of titles found.
@ -43,7 +43,7 @@ def title_search(title_search: str) -> int:
media_search_manager.clear()
table_show_manager.clear()
search_url = f"{site_constant.FULL_URL}/api/search?q={title_search}"
search_url = f"{site_constant.FULL_URL}/api/search?q={query}"
console.print(f"[cyan]Search url: [yellow]{search_url}")
try:

View File

@ -1,5 +1,5 @@
__title__ = 'StreamingCommunity'
__version__ = '2.9.5'
__version__ = '2.9.6'
__author__ = 'Arrowar'
__description__ = 'A command-line program to download film'
__copyright__ = 'Copyright 2024'

View File

@ -143,7 +143,7 @@ def initialize():
sys.exit(0)
# Trending tmbd
if SHOW_TRENDING:
"""if SHOW_TRENDING:
print()
tmdb.display_trending_films()
tmdb.display_trending_tv_shows()
@ -152,7 +152,7 @@ def initialize():
try:
git_update()
except:
console.log("[red]Error with loading github.")
console.log("[red]Error with loading github.")"""
def restart_script():
"""Riavvia lo script con gli stessi argomenti della riga di comando."""

View File

@ -10,7 +10,7 @@ with open(os.path.join(os.path.dirname(__file__), "requirements.txt"), "r", enco
setup(
name="StreamingCommunity",
version="2.9.5",
version="2.9.6",
long_description=read_readme(),
long_description_content_type="text/markdown",
author="Lovi-0",