Skip to content

Commit

Permalink
fix update
Browse files Browse the repository at this point in the history
  • Loading branch information
Lovi-0 committed Mar 16, 2024
1 parent 448be26 commit 5300ed9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 46 deletions.
39 changes: 21 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,37 @@
<img src="Src/Assets/min_logo.png" style="max-width: 55%;" alt="video working" />
</p>

## StreamingCommunity Downloader
<p align="center">
<img src="Src/Assets/run.gif" style="max-width: 55%;" alt="video working" />
</p>
## 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.

## 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

## 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.
# Table of Contents
* [INSTALLATION](#installation)
* [Requirement](#requirement)
* [Usage](#usage)
* [Update](#update)

* [FEATURES](#features)
* [USAGE AND OPTIONS](#options)
* [TUTORIAL](#tutorial)

## Requirement
Make sure you have the following prerequisites installed on your system:

* python > [3.11](https://www.python.org/downloads/)
* ffmpeg [win](https://www.gyan.dev/ffmpeg/builds/)

## Installation library

## Installation
Install the required Python libraries using the following command:
```
pip install -r requirements.txt
```

## Usage
Run the script with the following command:

#### On Windows:
```powershell
python run.py
Expand All @@ -37,28 +43,28 @@ python run.py
python3 run.py
```

## Auto Update

## Update
Keep your script up to date with the latest features by running:

#### On Windows:
```powershell
python update.py
```

#### On Linux/MacOS:
```bash
python3 update.py
```


## Features
- Download Single Film: Easily download individual movies with a simple command.

- Download Specific Episodes or Entire Series: Seamlessly retrieve specific episodes or entire series using intuitive commands. Specify a range of episodes with square brackets notation, e.g., [5-7], or download all episodes with an asterisk (*).

- Download Subtitles: Automatically fetch subtitles if available for downloaded content. (Note: To disable this feature, see [Configuration](#configuration))

- Sync Audio and Video: Ensure perfect synchronization between audio and video during the download process for an enhanced viewing experience.

## Configuration

You can change some behaviors by tweaking the configuration file.

```json
Expand All @@ -71,6 +77,7 @@ You can change some behaviors by tweaking the configuration file.
"selected_language": "English",
"max_worker": 20
}

```
#### Options
| Key | Default Value | Description | Value Example |
Expand All @@ -89,11 +96,7 @@ You can change some behaviors by tweaking the configuration file.
#### Path examples:

* Windows: `C:\\MyLibrary\\Folder` or `\\\\MyServer\\MyLibrary` (if you want to use a network folder).

* Linux/MacOS: `Desktop/MyLibrary/Folder`

## Tutorial
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)
For a detailed walkthrough, refer to the [video tutorial](https://www.youtube.com/watch?v=Ok7hQCgxqLg&ab_channel=Nothing)
Binary file removed Src/Assets/run.gif
Binary file not shown.
2 changes: 1 addition & 1 deletion Src/Upload/__version__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__title__ = 'Streaming_community'
__version__ = 'v0.9.0'
__version__ = 'v0.9.1'
__author__ = 'Ghost6446'
__description__ = 'A command-line program to download film'
__license__ = 'MIT License'
Expand Down
38 changes: 11 additions & 27 deletions update.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,93 +10,77 @@
console = Console()
local_path = os.path.join(".")

def move_content(source, destination):

def move_content(source: str, destination: str) :
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):
def keep_specific_items(directory: str, keep_folder: str, keep_file: str):

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 with admin privileges.")

except Exception as e:
print(f"Error: {e}")

def download_and_extract_latest_commit(author, repo_name):
def download_and_extract_latest_commit(author: str, repo_name: str):

# 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]Making a request to GitHub repository...")

if response.status_code == 200:
if response.ok:
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]Getting zip file from repository...")

# 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]Extracting 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(".", "videos", "upload.py")
cmd_insert = input("Are you sure you want to delete all files? (Only videos folder will remain) [yes/no]: ")

download_and_extract_latest_commit(repository_owner, repository_name)
if cmd_insert == "yes":
keep_specific_items(".", "videos", "upload.py")
download_and_extract_latest_commit(repository_owner, repository_name)

main_upload()

0 comments on commit 5300ed9

Please sign in to comment.