Add other special char, update readme with temux

This commit is contained in:
Ghost 2024-05-29 19:14:00 +02:00
parent c0a9fc1e6d
commit c86d2a8cac
5 changed files with 34 additions and 19 deletions

View File

@ -13,9 +13,13 @@ You can chat, help improve this repo, or just hang around for some fun in the **
* [INSTALLATION](#installation)
* [Requirement](#requirement)
* [Usage](#usage)
* [Win 7](https://github.com/Ghost6446/StreamingCommunity_api/wiki/Installation#win-7)
* [Termux](https://github.com/Ghost6446/StreamingCommunity_api/wiki/Termux)
* [CONFIGURATION](#Configuration)
* [DOCKER](#docker)
* [TUTORIAL](#tutorial)
* [TO DO](#to-do)
## Requirement
@ -49,6 +53,7 @@ python run.py
python3 run.py
```
## Configuration
You can change some behaviors by tweaking the configuration file.
@ -164,7 +169,7 @@ You can change some behaviors by tweaking the configuration file.
</details>
> [!IMPORTANT]
> If you're on **Windows** you'll need to use double black slashes. On Linux/MacOS, one slash is fine.
> If you're on **Windows** you'll need to use double back slash. On Linux/MacOS, one slash is fine.
#### Path examples:
@ -205,3 +210,9 @@ docker run -it -p 8000:8000 -v /path/to/download:/app/Video streaming-community-
## Tutorial
For a detailed walkthrough, refer to the [video tutorial](https://www.youtube.com/watch?v=Ok7hQCgxqLg&ab_channel=Nothing)
## To do
- GUI
- Website api
- Add other site

View File

@ -206,7 +206,7 @@ class Downloader():
logging.info(f"M3U8 index select: {self.m3u8_index}, with resolution: {video_res}")
# Get URI of the best quality and codecs parameters
console.log(f"[cyan]Find resolution [white]=> [red]{list_available_resolution}")
console.log(f"[cyan]Find resolution [white]=> [red]{sorted(list_available_resolution, reverse=True)}")
# Fix URL if it is not complete with http:\\site_name.domain\...
if "http" not in self.m3u8_index:

View File

@ -175,11 +175,12 @@ class M3U8_Segments:
# Send a GET request to retrieve the index M3U8 file
response = requests.get(self.url, headers=headers_index)
response.raise_for_status() # Raise an exception for HTTP errors
response.raise_for_status()
# Save the M3U8 file to the temporary folder
path_m3u8_file = os.path.join(self.tmp_folder, "playlist.m3u8")
open(path_m3u8_file, "w+").write(response.text)
if response.ok:
path_m3u8_file = os.path.join(self.tmp_folder, "playlist.m3u8")
open(path_m3u8_file, "w+").write(response.text)
# Parse the text from the M3U8 index file
self.parse_data(response.text)

View File

@ -434,8 +434,7 @@ class M3U8_Parser:
return resolution
# Default resolution return (not best)
logging.error("No resolution found with custom parsing.")
logging.warning("Try set remove duplicate line to TRUE.")
logging.warning("No resolution found with custom parsing.")
return (0, 0)
def __parse_video_info__(self, m3u8_obj) -> None:
@ -449,6 +448,15 @@ class M3U8_Parser:
try:
for playlist in m3u8_obj.playlists:
there_is_codec = not M3U8_Parser.extract_resolution(playlist.uri) == (0,0)
if there_is_codec:
self.codec = M3U8_Codec(
playlist.stream_info.bandwidth,
None,
playlist.stream_info.codecs
)
# Direct access resolutions in m3u8 obj
if playlist.stream_info.resolution is not None:
@ -456,6 +464,9 @@ class M3U8_Parser:
"uri": playlist.uri,
"resolution": playlist.stream_info.resolution
})
if there_is_codec:
self.codec.resolution = playlist.stream_info.resolution
# Find resolutions in uri
else:
@ -465,18 +476,10 @@ class M3U8_Parser:
"resolution": M3U8_Parser.extract_resolution(playlist.uri)
})
# Dont stop
continue
if there_is_codec:
self.codec.resolution = M3U8_Parser.extract_resolution(playlist.uri)
# Check if all key is present to create codec
try:
self.codec = M3U8_Codec(
playlist.stream_info.bandwidth,
playlist.stream_info.resolution,
playlist.stream_info.codecs
)
except:
logging.error(f"Error parsing codec: {e}")
continue
except Exception as e:
logging.error(f"Error parsing video info: {e}")

View File

@ -29,7 +29,7 @@ from .console import console
# --> OS FILE ASCII
special_chars_to_remove = ['!','@','#','$','%','^','&','*','(',')','[',']','{','}','<','|','`','~',"'",'"',';',':',',','?',"\\","/"]
special_chars_to_remove = ['!','@','#','$','%','^','&','*','(',')','[',']','{','}','<','|','`','~',"'",'"',';',':',',','?',"\\","/","\t"]
def get_max_length_by_os(system: str) -> int:
"""