mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 12:05:35 +00:00
parent
5300ed9fb5
commit
b7760bd3ce
@ -6,7 +6,7 @@
|
|||||||
This repository provide a simple script designed to facilitate the downloading of films and series from a popular streaming community platform. The script allows users to download individual films, entire series, or specific episodes, providing a seamless experience for content consumers.
|
This repository provide a simple script designed to facilitate the downloading of films and series from a popular streaming community platform. The script allows users to download individual films, entire series, or specific episodes, providing a seamless experience for content consumers.
|
||||||
|
|
||||||
## Join us
|
## Join us
|
||||||
You can chat, help improve this repo, or just hang around for some fun in the **Git_StreamingCommunity** Discord Server: https://discord.gg/RtHRvRXU
|
You can chat, help improve this repo, or just hang around for some fun in the **Git_StreamingCommunity** Discord Server: hhttps://discord.gg/8QRPaH6Y
|
||||||
|
|
||||||
# Table of Contents
|
# Table of Contents
|
||||||
* [INSTALLATION](#installation)
|
* [INSTALLATION](#installation)
|
||||||
|
34
run.py
34
run.py
@ -13,40 +13,60 @@ from Src.Lib.FFmpeg.installer import check_ffmpeg
|
|||||||
# Import
|
# Import
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
# [ main ]
|
def initialize() -> None:
|
||||||
def initialize():
|
"""
|
||||||
|
Initializes the application by performing necessary setup tasks.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Checking Python version
|
||||||
if sys.version_info < (3, 11):
|
if sys.version_info < (3, 11):
|
||||||
console.log("Install python version > 3.11")
|
console.log("Install python version > 3.11")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
# Removing temporary folder
|
||||||
remove_folder("tmp")
|
remove_folder("tmp")
|
||||||
msg_start()
|
msg_start()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# Updating application
|
||||||
main_update()
|
main_update()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
console.print(f"[blue]Request GitHub [white]=> [red]Failed: {e}")
|
console.print(f"[blue]Request GitHub [white]=> [red]Failed: {e}")
|
||||||
|
|
||||||
|
# Checking FFmpeg installation
|
||||||
check_ffmpeg()
|
check_ffmpeg()
|
||||||
print("\n")
|
print("\n")
|
||||||
|
|
||||||
def main():
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
"""
|
||||||
|
Main function to execute the application logic.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Initializing the application
|
||||||
initialize()
|
initialize()
|
||||||
|
|
||||||
|
# Retrieving domain and site version
|
||||||
domain, site_version = Page.domain_version()
|
domain, site_version = Page.domain_version()
|
||||||
|
|
||||||
|
# Searching for movie or TV series title
|
||||||
film_search = msg.ask("\n[blue]Search for any Movie or TV Series title").strip()
|
film_search = msg.ask("\n[blue]Search for any Movie or TV Series title").strip()
|
||||||
db_title = Page.search(film_search, domain)
|
db_title = Page.search(film_search, domain)
|
||||||
Page.display_search_results(db_title)
|
Page.display_search_results(db_title)
|
||||||
|
|
||||||
if len(db_title) != 0:
|
if db_title:
|
||||||
|
|
||||||
|
# Displaying total results
|
||||||
console.print(f"\n[blue]Total result: {len(db_title)}")
|
console.print(f"\n[blue]Total result: {len(db_title)}")
|
||||||
|
|
||||||
|
# Asking user to select title(s) to download
|
||||||
console.print(
|
console.print(
|
||||||
"\n[green]Insert [yellow]INDEX [red]number[green], or [red][1-2] [green]for a range of movies/tv series, or [red][1,3,5] [green]to select discontinued movie/tv series"
|
"\n[green]Insert [yellow]INDEX [red]number[green], or [red][1-2] [green]for a range of movies/tv series, or [red][1,3,5] [green]to select discontinued movie/tv series"
|
||||||
)
|
)
|
||||||
console.print("\n[red]In case of a TV Series you will also choose seasons and episodes to download")
|
console.print("\n[red]In case of a TV Series you will also choose seasons and episodes to download")
|
||||||
index_select = str(msg.ask("\n[blue]Select [yellow]INDEX [blue]to download"))
|
index_select = str(msg.ask("\n[blue]Select [yellow]INDEX [blue]to download")).strip()
|
||||||
|
|
||||||
|
# For only number ( to fix )
|
||||||
if index_select.isnumeric():
|
if index_select.isnumeric():
|
||||||
index_select = int(index_select)
|
index_select = int(index_select)
|
||||||
if 0 <= index_select <= len(db_title) - 1:
|
if 0 <= index_select <= len(db_title) - 1:
|
||||||
@ -60,6 +80,8 @@ def main():
|
|||||||
download_tv(selected_title['id'], selected_title['slug'], site_version, domain)
|
download_tv(selected_title['id'], selected_title['slug'], site_version, domain)
|
||||||
else:
|
else:
|
||||||
console.print("[red]Wrong INDEX for selection")
|
console.print("[red]Wrong INDEX for selection")
|
||||||
|
|
||||||
|
# For range like [5-15] ( to fix )
|
||||||
elif "[" in index_select:
|
elif "[" in index_select:
|
||||||
if "-" in index_select:
|
if "-" in index_select:
|
||||||
start, end = map(int, index_select[1:-1].split('-'))
|
start, end = map(int, index_select[1:-1].split('-'))
|
||||||
@ -72,6 +94,8 @@ def main():
|
|||||||
else:
|
else:
|
||||||
console.print(f"[green]\nSelected TV Series: {selected_title['name']}")
|
console.print(f"[green]\nSelected TV Series: {selected_title['name']}")
|
||||||
download_tv(selected_title['id'], selected_title['slug'], site_version, domain)
|
download_tv(selected_title['id'], selected_title['slug'], site_version, domain)
|
||||||
|
|
||||||
|
# For a list of specific ( to fix )
|
||||||
elif "," in index_select:
|
elif "," in index_select:
|
||||||
result = list(map(int, index_select[1:-1].split(',')))
|
result = list(map(int, index_select[1:-1].split(',')))
|
||||||
for n in result:
|
for n in result:
|
||||||
|
101
update.py
101
update.py
@ -1,6 +1,5 @@
|
|||||||
# 10.12.24
|
# 10.12.24
|
||||||
|
|
||||||
# General imports
|
|
||||||
import requests, os, shutil
|
import requests, os, shutil
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
@ -10,40 +9,86 @@ from rich.console import Console
|
|||||||
console = Console()
|
console = Console()
|
||||||
local_path = os.path.join(".")
|
local_path = os.path.join(".")
|
||||||
|
|
||||||
def move_content(source: str, destination: str) :
|
def move_content(source: str, destination: str) -> None:
|
||||||
os.makedirs(destination, exist_ok=True)
|
"""
|
||||||
|
Recursively moves content from source directory to destination directory.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
source (str): Path to the source directory.
|
||||||
|
destination (str): Path to the destination directory.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
None
|
||||||
|
"""
|
||||||
|
os.makedirs(destination, exist_ok=True)
|
||||||
for element in os.listdir(source):
|
for element in os.listdir(source):
|
||||||
source_path = os.path.join(source, element)
|
source_path = os.path.join(source, element)
|
||||||
destination_path = os.path.join(destination, element)
|
destination_path = os.path.join(destination, element)
|
||||||
|
|
||||||
if os.path.isdir(source_path):
|
if os.path.isdir(source_path):
|
||||||
move_content(source_path, destination_path)
|
move_content(source_path, destination_path)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
shutil.move(source_path, destination_path)
|
shutil.move(source_path, destination_path)
|
||||||
|
|
||||||
def keep_specific_items(directory: str, keep_folder: str, keep_file: str):
|
def delete_files_folders(main_directory_path: str, folders_to_exclude: list = [], files_to_exclude: list = []) -> None:
|
||||||
|
"""
|
||||||
|
Deletes files and folders from the specified directory except those specified.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
main_directory_path (str): Path to the main directory.
|
||||||
|
folders_to_exclude (list): List of folder names to exclude from deletion.
|
||||||
|
files_to_exclude (list): List of file names to exclude from deletion.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
None
|
||||||
|
"""
|
||||||
|
for root, dirs, files in os.walk(main_directory_path, topdown=False):
|
||||||
|
for name in files:
|
||||||
|
file_path = os.path.join(root, name)
|
||||||
|
if name not in files_to_exclude:
|
||||||
try:
|
try:
|
||||||
if not os.path.exists(directory) or not os.path.isdir(directory):
|
os.remove(file_path)
|
||||||
raise ValueError(f"Error: '{directory}' is not a valid directory.")
|
except:
|
||||||
|
pass
|
||||||
|
for name in dirs:
|
||||||
|
dir_path = os.path.join(root, name)
|
||||||
|
if name not in folders_to_exclude:
|
||||||
|
try:
|
||||||
|
os.rmdir(dir_path)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
for item in os.listdir(directory):
|
def list_files_and_folders(directory: str, files_to_remove: list = []) -> None:
|
||||||
item_path = os.path.join(directory, item)
|
"""
|
||||||
if os.path.isdir(item_path) and item != keep_folder:
|
Lists files and folders in the specified directory and removes those specified.
|
||||||
shutil.rmtree(item_path)
|
|
||||||
elif os.path.isfile(item_path) and item != keep_file:
|
|
||||||
os.remove(item_path)
|
|
||||||
|
|
||||||
except PermissionError as pe:
|
Args:
|
||||||
print(f"PermissionError: {pe}. Check permissions and try running the script with admin privileges.")
|
directory (str): Path to the directory to list files and folders.
|
||||||
|
files_to_remove (list): List of file names to remove.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
None
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
for root, dirs, files in os.walk(directory):
|
||||||
|
for file_name in files:
|
||||||
|
file_path = os.path.join(root, file_name)
|
||||||
|
if file_name in files_to_remove:
|
||||||
|
os.remove(file_path)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error: {e}")
|
print(f"Error occurred: {e}")
|
||||||
|
|
||||||
def download_and_extract_latest_commit(author: str, repo_name: str):
|
def download_and_extract_latest_commit(author: str, repo_name: str, exclude_files: list) -> None:
|
||||||
|
"""
|
||||||
|
Downloads and extracts the latest commit from a GitHub repository.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
author (str): The username of the repository owner.
|
||||||
|
repo_name (str): The name of the repository.
|
||||||
|
exclude_files (list): List of file names to exclude from extraction.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
None
|
||||||
|
"""
|
||||||
api_url = f'https://api.github.com/repos/{author}/{repo_name}/commits?per_page=1'
|
api_url = f'https://api.github.com/repos/{author}/{repo_name}/commits?per_page=1'
|
||||||
response = requests.get(api_url)
|
response = requests.get(api_url)
|
||||||
console.log("[green]Making a request to GitHub repository...")
|
console.log("[green]Making a request to GitHub repository...")
|
||||||
@ -60,6 +105,8 @@ def download_and_extract_latest_commit(author: str, repo_name: str):
|
|||||||
zip_ref.extractall(temp_path)
|
zip_ref.extractall(temp_path)
|
||||||
console.log("[green]Extracting file ...")
|
console.log("[green]Extracting file ...")
|
||||||
|
|
||||||
|
list_files_and_folders(temp_path, exclude_files)
|
||||||
|
|
||||||
for item in os.listdir(temp_path):
|
for item in os.listdir(temp_path):
|
||||||
item_path = os.path.join(temp_path, item)
|
item_path = os.path.join(temp_path, item)
|
||||||
destination_path = os.path.join(local_path, item)
|
destination_path = os.path.join(local_path, item)
|
||||||
@ -73,14 +120,24 @@ def download_and_extract_latest_commit(author: str, repo_name: str):
|
|||||||
else:
|
else:
|
||||||
console.log(f"[red]Failed to fetch commit information. Status code: {response.status_code}")
|
console.log(f"[red]Failed to fetch commit information. Status code: {response.status_code}")
|
||||||
|
|
||||||
def main_upload():
|
def main_upload() -> None:
|
||||||
|
"""
|
||||||
|
Main function to upload the latest changes from a GitHub repository.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
None
|
||||||
|
"""
|
||||||
repository_owner = 'Ghost6446'
|
repository_owner = 'Ghost6446'
|
||||||
repository_name = 'StreamingCommunity_api'
|
repository_name = 'StreamingCommunity_api'
|
||||||
|
|
||||||
cmd_insert = input("Are you sure you want to delete all files? (Only videos folder will remain) [yes/no]: ")
|
cmd_insert = input("Are you sure you want to delete all files? (Only videos folder will remain) [yes/no]: ")
|
||||||
|
|
||||||
if cmd_insert == "yes":
|
if cmd_insert.lower() == "yes" or cmd_insert.lower() == "y":
|
||||||
keep_specific_items(".", "videos", "upload.py")
|
delete_files_folders(
|
||||||
download_and_extract_latest_commit(repository_owner, repository_name)
|
main_directory_path=".",
|
||||||
|
folders_to_exclude=["videos"],
|
||||||
|
files_to_exclude=["upload.py", "config.json"]
|
||||||
|
)
|
||||||
|
download_and_extract_latest_commit(repository_owner, repository_name, ["config.json"])
|
||||||
|
|
||||||
main_upload()
|
main_upload()
|
Loading…
x
Reference in New Issue
Block a user