diff --git a/README.md b/README.md index e30c75f..6b83182 100644 --- a/README.md +++ b/README.md @@ -3,40 +3,43 @@

## Streaming community downloader - -Script to download film from streaming community without selenium, select movie or series and download single ep. -

video working

+## Overview. +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. + ## Requirement +Make sure you have the following prerequisites installed on your system: * python [3.9](https://www.python.org/downloads/release/python-390/) * ffmpeg [win](https://www.gyan.dev/ffmpeg/builds/) ## Installation library - +Install the required Python libraries using the following command: ```bash pip install -r requirements.txt ``` -## Run - -```bash +## Usage +Run the script with the following command: +```python python run.py ``` -## Features +## Auto Update +Keep your script up to date with the latest features by running: +```python +python update.py +``` -- Search for movies. -- Search and download TV series episode. -- Auto add audio if missing +## Features +- Download single film. +- Download specific episodes or entire series with command (*). ## Tutorial - -https://www.youtube.com/watch?v=Ok7hQCgxqLg&ab_channel=Nothing +For a detailed walkthrough, refer to the [video tutorial](https://www.youtube.com/watch?v=Ok7hQCgxqLg&ab_channel=Nothing) ## Authors - - [@Ghost6446](https://www.github.com/Ghost6446) diff --git a/Src/Upload/update.py b/Src/Upload/update.py index a31943a..eba191e 100644 --- a/Src/Upload/update.py +++ b/Src/Upload/update.py @@ -34,7 +34,7 @@ def main_update(): if get_install_version() != last_version: console.print(f"[red]=> A new version is available: [green]{json['zipball_url']}") console.print(f"[red]=> Versione: [yellow]{json['name']}") - + else: console.print(f"[red]=> Everything up to date") console.print(f"[red]=> Last version: [yellow]{json['name']}") diff --git a/Src/Util/Helper/os.py b/Src/Util/Helper/os.py index 3872c68..18d083d 100644 --- a/Src/Util/Helper/os.py +++ b/Src/Util/Helper/os.py @@ -8,6 +8,4 @@ def remove_folder(folder_path): try: shutil.rmtree(folder_path) except OSError as e: - print(f"Error removing folder '{folder_path}': {e}") - else: - print(f"Folder '{folder_path}' does not exist.") \ No newline at end of file + print(f"Error removing folder '{folder_path}': {e}") \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index e9c25ac..e9d6a44 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,5 +5,5 @@ tqdm rich random-user-agent ffmpeg-python -cryptography +cryptography==3.4.8 # Problem with new version moviepy diff --git a/run.py b/run.py index 8371f00..ef38716 100644 --- a/run.py +++ b/run.py @@ -13,38 +13,45 @@ from Src.Util.Helper.os import remove_folder # General import import sys -# Variable -domain, site_version = Page.domain_version() - -def main(): +def initialize(): + remove_folder("tmp") msg_start() - try: + try: main_update() - except: - console.print("[blue]Req github [white]=> [red]Failed") + except Exception as e: + console.print(f"[blue]Req github [white]=> [red]Failed: {e}") console.print(f"[blue]Find system [white]=> [red]{sys.platform}") check_ffmpeg() print("\n") - + +def display_search_results(db_title): + for i, title in enumerate(db_title): + console.print(f"[yellow]{i} [white]-> [green]{title['name']} [white]- [cyan]{title['type']}") + +def main(): + + initialize() + domain, site_version = Page.domain_version() + film_search = msg.ask("\n[blue]Insert word to search in all site: ").strip() db_title = Page.search(film_search, domain) + display_search_results(db_title) - for i in range(len(db_title)): - console.print(f"[yellow]{i} [white]-> [green]{db_title[i]['name']} [white]- [cyan]{db_title[i]['type']}") index_select = int(msg.ask("\n[blue]Index to download: ")) - if 0 <= index_select <= len(db_title)-1: - if db_title[index_select]['type'] == "movie": - console.print(f"[green]\nMovie select: {db_title[index_select]['name']}") - download_film(db_title[index_select]['id'], db_title[index_select]['slug'], domain) + if 0 <= index_select <= len(db_title) - 1: + selected_title = db_title[index_select] + if selected_title['type'] == "movie": + console.print(f"[green]\nMovie select: {selected_title['name']}") + download_film(selected_title['id'], selected_title['slug'], domain) else: - console.print(f"[green]\nTv select: {db_title[index_select]['name']}") - download_tv(db_title[index_select]['id'], db_title[index_select]['slug'], site_version, domain) + console.print(f"[green]\nTv select: {selected_title['name']}") + download_tv(selected_title['id'], selected_title['slug'], site_version, domain) else: console.print("[red]Wrong index for selection") @@ -52,4 +59,4 @@ def main(): console.print("\n[red]Done") if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/update.py b/update.py new file mode 100644 index 0000000..d18796e --- /dev/null +++ b/update.py @@ -0,0 +1,102 @@ +# 10.12.24 + +# General imports +import requests, os, shutil +from zipfile import ZipFile +from io import BytesIO +from rich.console import Console + +# Variable +console = Console() +local_path = os.path.join(".") + +def move_content(source, destination): + + os.makedirs(destination, exist_ok=True) + + # Iterate through all elements in the source folder + for element in os.listdir(source): + source_path = os.path.join(source, element) + destination_path = os.path.join(destination, element) + + # If it's a directory, recursively call the function + if os.path.isdir(source_path): + move_content(source_path, destination_path) + else: + # Otherwise, move the file, replacing if it already exists + shutil.move(source_path, destination_path) + +def keep_specific_items(directory, keep_folder, keep_file): + try: + if not os.path.exists(directory) or not os.path.isdir(directory): + raise ValueError(f"Error: '{directory}' is not a valid directory.") + + # Iterate through items in the directory + for item in os.listdir(directory): + item_path = os.path.join(directory, item) + + # Check if the item is the specified folder or file + if os.path.isdir(item_path) and item != keep_folder: + shutil.rmtree(item_path) + elif os.path.isfile(item_path) and item != keep_file: + os.remove(item_path) + + except PermissionError as pe: + print(f"PermissionError: {pe}. Check permissions and try running the script as administrator.") + except Exception as e: + print(f"Error: {e}") + +def download_and_extract_latest_commit(author, repo_name): + + # Get the latest commit information using GitHub API + api_url = f'https://api.github.com/repos/{author}/{repo_name}/commits?per_page=1' + response = requests.get(api_url) + console.log("[green]Make req repo github") + + if response.status_code == 200: + commit_info = response.json()[0] + commit_sha = commit_info['sha'] + zipball_url = f'https://github.com/{author}/{repo_name}/archive/{commit_sha}.zip' + console.log("[green]Get zip file from repo") + + # Download the zipball + response = requests.get(zipball_url) + + # Extract the content of the zipball into a temporary folder + temp_path = os.path.join(os.path.dirname(os.getcwd()), 'temp_extracted') + with ZipFile(BytesIO(response.content)) as zip_ref: + zip_ref.extractall(temp_path) + console.log("[green]Extract file ...") + + + # Move files from the temporary folder to the current folder + for item in os.listdir(temp_path): + item_path = os.path.join(temp_path, item) + destination_path = os.path.join(local_path, item) + shutil.move(item_path, destination_path) + + # Remove the temporary folder + shutil.rmtree(temp_path) + + # Move all folder to main folder + new_folder_name = f"{repo_name}-{commit_sha}" + move_content(new_folder_name, ".") + + # Remove old temp folder + shutil.rmtree(new_folder_name) + + console.log(f"[cyan]Latest commit downloaded and extracted successfully.") + else: + console.log(f"[red]Failed to fetch commit information. Status code: {response.status_code}") + +def main_upload(): + + repository_owner = 'Ghost6446' + repository_name = 'StreamingCommunity_api' + + # Remove all old file + keep_specific_items(".", "video", "upload.py") + + download_and_extract_latest_commit(repository_owner, repository_name) + +main_upload() \ No newline at end of file