mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-06 19:45:24 +00:00
hls: Fix bug add_ts_file
This commit is contained in:
parent
48e433d2fb
commit
23b576e4b6
115
.github/workflows/build.yml
vendored
115
.github/workflows/build.yml
vendored
@ -1,4 +1,4 @@
|
|||||||
name: Build or Publish
|
name: Build and Publish
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
@ -17,7 +17,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
if: (startsWith(github.ref_name, 'v') || github.event_name == 'workflow_dispatch') && github.event.inputs.publish_pypi == 'true'
|
if: startsWith(github.ref_name, 'v') || (github.event_name == 'workflow_dispatch' && github.event.inputs.publish_pypi == 'true')
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@ -33,7 +33,7 @@ jobs:
|
|||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.11'
|
python-version: '3.12'
|
||||||
|
|
||||||
- name: Install packaging dependencies
|
- name: Install packaging dependencies
|
||||||
run: |
|
run: |
|
||||||
@ -50,10 +50,31 @@ jobs:
|
|||||||
run: twine upload dist/*
|
run: twine upload dist/*
|
||||||
|
|
||||||
build:
|
build:
|
||||||
if: (startsWith(github.ref_name, 'v') || github.event_name == 'workflow_dispatch') && github.event.inputs.publish_pypi == 'false'
|
if: startsWith(github.ref_name, 'v') || (github.event_name == 'workflow_dispatch' && github.event.inputs.publish_pypi == 'false')
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [windows-latest, ubuntu-latest, macos-latest]
|
include:
|
||||||
|
- os: windows-latest
|
||||||
|
artifact_name: StreamingCommunity_win
|
||||||
|
executable: StreamingCommunity_win.exe
|
||||||
|
separator: ';'
|
||||||
|
|
||||||
|
- os: macos-latest
|
||||||
|
artifact_name: StreamingCommunity_mac
|
||||||
|
executable: StreamingCommunity_mac
|
||||||
|
separator: ':'
|
||||||
|
|
||||||
|
- os: ubuntu-latest
|
||||||
|
artifact_name: StreamingCommunity_linux_latest
|
||||||
|
executable: StreamingCommunity_linux_latest
|
||||||
|
separator: ':'
|
||||||
|
|
||||||
|
- os: ubuntu-20.04
|
||||||
|
artifact_name: StreamingCommunity_linux_previous
|
||||||
|
executable: StreamingCommunity_linux_previous
|
||||||
|
separator: ':'
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@ -68,43 +89,19 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
$latestTag = git describe --tags --abbrev=0
|
$latestTag = git describe --tags --abbrev=0
|
||||||
echo "latest_tag=$latestTag" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
echo "latest_tag=$latestTag" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.11'
|
python-version: '3.12'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
python -m pip install -r requirements.txt
|
python -m pip install -r requirements.txt
|
||||||
python -m pip install pyinstaller
|
python -m pip install pyinstaller
|
||||||
- name: Build executable with PyInstaller (Windows)
|
|
||||||
if: matrix.os == 'windows-latest'
|
|
||||||
shell: pwsh
|
|
||||||
run: |
|
|
||||||
pyinstaller --onefile --hidden-import=pycryptodomex --hidden-import=ua_generator `
|
|
||||||
--hidden-import=qbittorrentapi --hidden-import=qbittorrent `
|
|
||||||
--hidden-import=bs4 --hidden-import=httpx --hidden-import=rich --hidden-import=tqdm `
|
|
||||||
--hidden-import=m3u8 --hidden-import=psutil --hidden-import=unidecode `
|
|
||||||
--hidden-import=jsbeautifier --hidden-import=jsbeautifier.core `
|
|
||||||
--hidden-import=jsbeautifier.javascript --hidden-import=jsbeautifier.javascript.beautifier `
|
|
||||||
--hidden-import=jsbeautifier.unpackers --hidden-import=jsbeautifier.unpackers.packer `
|
|
||||||
--hidden-import=jsbeautifier.unpackers.javascriptobfuscator `
|
|
||||||
--hidden-import=jsbeautifier.unpackers.myobfuscate `
|
|
||||||
--hidden-import=jsbeautifier.unpackers.urlencode `
|
|
||||||
--hidden-import=jsbeautifier.unpackers.meshim `
|
|
||||||
--hidden-import=editorconfig --hidden-import=editorconfig.handlers `
|
|
||||||
--hidden-import=six --hidden-import=pathvalidate `
|
|
||||||
--hidden-import=Cryptodome.Cipher --hidden-import=Cryptodome.Cipher.AES `
|
|
||||||
--hidden-import=Cryptodome.Util --hidden-import=Cryptodome.Util.Padding `
|
|
||||||
--hidden-import=Cryptodome.Random `
|
|
||||||
--hidden-import=telebot `
|
|
||||||
--additional-hooks-dir=pyinstaller/hooks `
|
|
||||||
--add-data "StreamingCommunity;StreamingCommunity" `
|
|
||||||
--name=StreamingCommunity_win --icon=".github/media/logo.ico" test_run.py
|
|
||||||
|
|
||||||
- name: Build executable with PyInstaller (Linux)
|
- name: Build executable with PyInstaller
|
||||||
if: matrix.os == 'ubuntu-latest'
|
|
||||||
run: |
|
run: |
|
||||||
pyinstaller --onefile --hidden-import=pycryptodomex --hidden-import=ua_generator \
|
pyinstaller --onefile --hidden-import=pycryptodomex --hidden-import=ua_generator \
|
||||||
--hidden-import=qbittorrentapi --hidden-import=qbittorrent \
|
--hidden-import=qbittorrentapi --hidden-import=qbittorrent \
|
||||||
@ -124,61 +121,19 @@ jobs:
|
|||||||
--hidden-import=Cryptodome.Random \
|
--hidden-import=Cryptodome.Random \
|
||||||
--hidden-import=telebot \
|
--hidden-import=telebot \
|
||||||
--additional-hooks-dir=pyinstaller/hooks \
|
--additional-hooks-dir=pyinstaller/hooks \
|
||||||
--add-data "StreamingCommunity:StreamingCommunity" \
|
--add-data "StreamingCommunity${{ matrix.separator }}StreamingCommunity" \
|
||||||
--name=StreamingCommunity_linux test_run.py
|
--name=${{ matrix.artifact_name }} --icon=".github/media/logo.ico" test_run.py
|
||||||
|
|
||||||
- name: Build executable with PyInstaller (macOS)
|
- name: Upload executable
|
||||||
if: matrix.os == 'macos-latest'
|
|
||||||
run: |
|
|
||||||
pyinstaller --onefile --hidden-import=pycryptodomex --hidden-import=ua_generator \
|
|
||||||
--hidden-import=qbittorrentapi --hidden-import=qbittorrent \
|
|
||||||
--hidden-import=bs4 --hidden-import=httpx --hidden-import=rich --hidden-import=tqdm \
|
|
||||||
--hidden-import=m3u8 --hidden-import=psutil --hidden-import=unidecode \
|
|
||||||
--hidden-import=jsbeautifier --hidden-import=jsbeautifier.core \
|
|
||||||
--hidden-import=jsbeautifier.javascript --hidden-import=jsbeautifier.javascript.beautifier \
|
|
||||||
--hidden-import=jsbeautifier.unpackers --hidden-import=jsbeautifier.unpackers.packer \
|
|
||||||
--hidden-import=jsbeautifier.unpackers.javascriptobfuscator \
|
|
||||||
--hidden-import=jsbeautifier.unpackers.myobfuscate \
|
|
||||||
--hidden-import=jsbeautifier.unpackers.urlencode \
|
|
||||||
--hidden-import=jsbeautifier.unpackers.meshim \
|
|
||||||
--hidden-import=editorconfig --hidden-import=editorconfig.handlers \
|
|
||||||
--hidden-import=six --hidden-import=pathvalidate \
|
|
||||||
--hidden-import=Cryptodome.Cipher --hidden-import=Cryptodome.Cipher.AES \
|
|
||||||
--hidden-import=Cryptodome.Util --hidden-import=Cryptodome.Util.Padding \
|
|
||||||
--hidden-import=Cryptodome.Random \
|
|
||||||
--hidden-import=telebot \
|
|
||||||
--additional-hooks-dir=pyinstaller/hooks \
|
|
||||||
--add-data "StreamingCommunity:StreamingCommunity" \
|
|
||||||
--name=StreamingCommunity_mac test_run.py
|
|
||||||
|
|
||||||
- name: Upload executable (Windows)
|
|
||||||
if: matrix.os == 'windows-latest'
|
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: StreamingCommunity_win
|
name: ${{ matrix.artifact_name }}
|
||||||
path: dist/StreamingCommunity_win.exe
|
path: dist/${{ matrix.executable }}
|
||||||
|
|
||||||
- name: Upload executable (Linux)
|
|
||||||
if: matrix.os == 'ubuntu-latest'
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: StreamingCommunity_linux
|
|
||||||
path: dist/StreamingCommunity_linux
|
|
||||||
|
|
||||||
- name: Upload executable (macOS)
|
|
||||||
if: matrix.os == 'macos-latest'
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: StreamingCommunity_mac
|
|
||||||
path: dist/StreamingCommunity_mac
|
|
||||||
|
|
||||||
- name: Create or update release
|
- name: Create or update release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ env.latest_tag }}
|
tag_name: ${{ env.latest_tag }}
|
||||||
files: |
|
files: dist/${{ matrix.executable }}
|
||||||
dist/StreamingCommunity_win.exe
|
|
||||||
dist/StreamingCommunity_linux
|
|
||||||
dist/StreamingCommunity_mac
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
@ -223,14 +223,12 @@ class M3U8_Segments:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
with self._get_http_client() as client:
|
with self._get_http_client() as client:
|
||||||
start_time = time.time()
|
|
||||||
response = client.get(ts_url)
|
response = client.get(ts_url)
|
||||||
|
|
||||||
# Validate response and content
|
# Validate response and content
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
segment_content = response.content
|
segment_content = response.content
|
||||||
content_size = len(segment_content)
|
content_size = len(segment_content)
|
||||||
duration = time.time() - start_time
|
|
||||||
|
|
||||||
# Decrypt if needed and verify decrypted content
|
# Decrypt if needed and verify decrypted content
|
||||||
if self.decryption is not None:
|
if self.decryption is not None:
|
||||||
@ -243,7 +241,7 @@ class M3U8_Segments:
|
|||||||
self.stop_event.set() # Trigger the stopping event for all threads
|
self.stop_event.set() # Trigger the stopping event for all threads
|
||||||
break # Stop the current task immediately
|
break # Stop the current task immediately
|
||||||
|
|
||||||
self.class_ts_estimator.update_progress_bar(content_size, duration, progress_bar)
|
self.class_ts_estimator.update_progress_bar(content_size, progress_bar)
|
||||||
self.queue.put((index, segment_content))
|
self.queue.put((index, segment_content))
|
||||||
self.downloaded_segments.add(index)
|
self.downloaded_segments.add(index)
|
||||||
progress_bar.update(1)
|
progress_bar.update(1)
|
||||||
|
@ -27,7 +27,6 @@ class M3U8_Ts_Estimator:
|
|||||||
- total_segments (int): Length of total segments to download.
|
- total_segments (int): Length of total segments to download.
|
||||||
"""
|
"""
|
||||||
self.ts_file_sizes = []
|
self.ts_file_sizes = []
|
||||||
self.now_downloaded_size = 0
|
|
||||||
self.total_segments = total_segments
|
self.total_segments = total_segments
|
||||||
self.segments_instance = segments_instance
|
self.segments_instance = segments_instance
|
||||||
self.lock = threading.Lock()
|
self.lock = threading.Lock()
|
||||||
@ -42,15 +41,13 @@ class M3U8_Ts_Estimator:
|
|||||||
else:
|
else:
|
||||||
logging.debug("USE_LARGE_BAR is False, speed capture thread not started")
|
logging.debug("USE_LARGE_BAR is False, speed capture thread not started")
|
||||||
|
|
||||||
def add_ts_file(self, size: int, size_download: int, duration: float):
|
def add_ts_file(self, size: int):
|
||||||
"""Add a file size to the list of file sizes."""
|
"""Add a file size to the list of file sizes."""
|
||||||
if size <= 0 or size_download <= 0 or duration <= 0:
|
if size <= 0:
|
||||||
logging.error(f"Invalid input values: size={size}, size_download={size_download}, duration={duration}")
|
logging.error(f"Invalid input values: size={size}")
|
||||||
return
|
return
|
||||||
|
|
||||||
self.ts_file_sizes.append(size)
|
self.ts_file_sizes.append(size)
|
||||||
self.now_downloaded_size += size_download
|
|
||||||
logging.debug(f"Current total downloaded size: {self.now_downloaded_size}")
|
|
||||||
|
|
||||||
def capture_speed(self, interval: float = 1.5):
|
def capture_speed(self, interval: float = 1.5):
|
||||||
"""Capture the internet speed periodically."""
|
"""Capture the internet speed periodically."""
|
||||||
@ -99,9 +96,9 @@ class M3U8_Ts_Estimator:
|
|||||||
logging.error("An unexpected error occurred: %s", e)
|
logging.error("An unexpected error occurred: %s", e)
|
||||||
return "Error"
|
return "Error"
|
||||||
|
|
||||||
def update_progress_bar(self, total_downloaded: int, duration: float, progress_counter: tqdm) -> None:
|
def update_progress_bar(self, total_downloaded: int, progress_counter: tqdm) -> None:
|
||||||
try:
|
try:
|
||||||
self.add_ts_file(total_downloaded * self.total_segments, total_downloaded, duration)
|
self.add_ts_file(total_downloaded * self.total_segments)
|
||||||
|
|
||||||
file_total_size = self.calculate_total_size()
|
file_total_size = self.calculate_total_size()
|
||||||
number_file_total_size = file_total_size.split(' ')[0]
|
number_file_total_size = file_total_size.split(' ')[0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user