From 5a8ece17d67ca20e343d5703aa05e467abbca230 Mon Sep 17 00:00:00 2001 From: Lovi <62809003+Lovi-0@users.noreply.github.com> Date: Fri, 7 Feb 2025 15:15:53 +0100 Subject: [PATCH] Fix workflows --- {Test/Media => .github/media}/loc-badge.json | 0 .../62809003.ico => .github/media/logo.ico | Bin .github/workflows/build.yml | 180 +++++++++++------- .../{update-loc-badge.yml => update-loc.yml} | 6 +- README.md | 2 +- .../Api/Site/animeunity/film_serie.py | 3 +- .../Api/Site/ddlstreamitaly/series.py | 3 +- .../Api/Site/guardaserie/series.py | 4 +- .../Api/Site/streamingcommunity/series.py | 3 +- config.json | 8 +- requirements.txt | 2 +- setup.py | 2 +- 12 files changed, 134 insertions(+), 79 deletions(-) rename {Test/Media => .github/media}/loc-badge.json (100%) rename Test/Media/62809003.ico => .github/media/logo.ico (100%) rename .github/workflows/{update-loc-badge.yml => update-loc.yml} (81%) diff --git a/Test/Media/loc-badge.json b/.github/media/loc-badge.json similarity index 100% rename from Test/Media/loc-badge.json rename to .github/media/loc-badge.json diff --git a/Test/Media/62809003.ico b/.github/media/logo.ico similarity index 100% rename from Test/Media/62809003.ico rename to .github/media/logo.ico diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 76c1af8..69be0bb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,80 +1,130 @@ -name: Build with PyInstaller +name: Build or Publish on: workflow_dispatch: + inputs: + publish_pypi: + description: 'Pubblicare su PyPI (true) o compilare eseguibili? (false)' + required: true + default: 'false' + type: choice + options: + - 'true' + - 'false' + push: + tags: + - "*" # Il workflow si eseguirà quando viene fatto un push con qualsiasi tag jobs: - build: - runs-on: windows-latest + publish: + if: github.event.inputs.publish_pypi == 'true' # Solo se publish_pypi è true + runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Recupera tutti i tag e la cronologia dei commit - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.11' + - name: Get the latest tag + id: get_latest_tag + run: echo "latest_tag=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV - - name: Cache Python dependencies - uses: actions/cache@v4 - with: - path: C:\Users\runneradmin\AppData\Local\pip\Cache - key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install -r requirements.txt - python -m pip install fake-useragent==1.1.3 pyinstaller + - name: Install packaging dependencies + run: | + echo "Installing packaging dependencies" + python -m pip install --upgrade pip + python -m pip install setuptools wheel twine - - name: Build executable with PyInstaller - shell: bash - run: | - set -e - pyinstaller --onefile --hidden-import=pycryptodomex --hidden-import=fake_useragent --hidden-import=qbittorrentapi \ - --hidden-import=qbittorrent --hidden-import=googlesearch --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=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=Pillow --hidden-import=pyTelegramBotAPI \ - --additional-hooks-dir=pyinstaller/hooks --add-data "StreamingCommunity;StreamingCommunity" \ - --name=StreamingCommunity --icon="Test/Media/62809003.ico" test_run.py + - name: Build package + run: | + echo "Building the package" + python setup.py sdist bdist_wheel - - name: Verify build output - shell: bash - run: | - if [ ! -f "dist/StreamingCommunity.exe" ]; then - echo "Errore: il file dist/StreamingCommunity.exe non esiste!" - exit 1 - fi + - name: Upload to PyPI + env: + TWINE_USERNAME: __token__ # Usa '__token__' per l'autenticazione con PyPI + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: | + echo "Uploading package to PyPI" + twine upload dist/* - - name: Upload executable as artifact - uses: actions/upload-artifact@v4 - with: - name: StreamingCommunity - path: dist/StreamingCommunity.exe + build: + if: github.event.inputs.publish_pypi == 'false' # Solo se publish_pypi è false + strategy: + matrix: + os: [windows-latest, ubuntu-latest] # Compila per Windows e Linux + runs-on: ${{ matrix.os }} - - name: Get latest tag from GitHub - id: get_latest_tag - shell: bash - run: | - TAG=$(curl -s https://api.github.com/repos/Arrowar/StreamingCommunity/releases/latest | jq -r '.tag_name') - if [[ "$TAG" == "null" || -z "$TAG" ]]; then - echo "Nessun tag trovato, impostazione di default a v1.0.0" - TAG="v1.0.0" - fi - echo "Latest tag: $TAG" - echo "latest_tag=$TAG" >> $GITHUB_ENV - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Recupera tutti i tag e la cronologia dei commit - - name: Create or update GitHub release - uses: softprops/action-gh-release@v1 - with: - tag_name: ${{ env.latest_tag }} - files: dist/StreamingCommunity.exe - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Get the latest tag + id: get_latest_tag + run: echo "latest_tag=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Install dependencies + run: | + echo "Installing dependencies" + python -m pip install --upgrade pip + python -m pip install -r requirements.txt + python -m pip install pyinstaller + python -m pip install fake-useragent==1.1.3 # Aggiunta dipendenza fake-useragent + + - name: Build executable with PyInstaller (Windows) + if: matrix.os == 'windows-latest' + shell: cmd + run: | + echo "Building Windows executable with PyInstaller" + pyinstaller --onefile --hidden-import=pycryptodomex --hidden-import=fake_useragent --hidden-import=qbittorrentapi --hidden-import=qbittorrent --hidden-import=googlesearch --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=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=Pillow --hidden-import=pyTelegramBotAPI --additional-hooks-dir=pyinstaller/hooks --add-data "StreamingCommunity;StreamingCommunity" --name=StreamingCommunity --icon=".github/media/logo.ico" test_run.py + + - name: Build executable with PyInstaller (Linux) + if: matrix.os == 'ubuntu-latest' + shell: bash + run: | + echo "Building Linux executable with PyInstaller" + pyinstaller --onefile --hidden-import=pycryptodomex --hidden-import=fake_useragent --hidden-import=qbittorrentapi \ + --hidden-import=qbittorrent --hidden-import=googlesearch --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=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=Pillow --hidden-import=pyTelegramBotAPI \ + --additional-hooks-dir=pyinstaller/hooks --add-data "StreamingCommunity:StreamingCommunity" \ + --name=StreamingCommunity test_run.py + + - name: Upload executable (Windows) + if: matrix.os == 'windows-latest' + uses: actions/upload-artifact@v4 + with: + name: StreamingCommunity-Windows + path: dist/StreamingCommunity.exe + + - name: Upload executable (Linux) + if: matrix.os == 'ubuntu-latest' + uses: actions/upload-artifact@v4 + with: + name: StreamingCommunity-Linux + path: dist/StreamingCommunity + + - name: Create or update release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ env.latest_tag }} # Usa l'ultimo tag come nome del release + files: | + dist/StreamingCommunity.exe + dist/StreamingCommunity + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/update-loc-badge.yml b/.github/workflows/update-loc.yml similarity index 81% rename from .github/workflows/update-loc-badge.yml rename to .github/workflows/update-loc.yml index eadfba5..aad590e 100644 --- a/.github/workflows/update-loc-badge.yml +++ b/.github/workflows/update-loc.yml @@ -1,4 +1,4 @@ -name: Update Lines of Code Badge +name: Update Lines of Code on: schedule: @@ -18,12 +18,12 @@ jobs: - name: Count Lines of Code run: | LOC=$(cloc . --json | jq '.SUM.code') - echo "{\"schemaVersion\": 1, \"label\": \"Lines of Code\", \"message\": \"$LOC\", \"color\": \"green\"}" > Test/Media/loc-badge.json + echo "{\"schemaVersion\": 1, \"label\": \"Lines of Code\", \"message\": \"$LOC\", \"color\": \"green\"}" > .github/media/loc-badge.json - name: Commit and Push LOC Badge run: | git config --local user.name "GitHub Actions" git config --local user.email "actions@github.com" - git add Test/Media/loc-badge.json + git add .github/media/loc-badge.json git commit -m "Update lines of code badge" || echo "No changes to commit" git push \ No newline at end of file diff --git a/README.md b/README.md index 04a5bd2..f584f07 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ PyPI Downloads - Lines of Code + Lines of Code

diff --git a/StreamingCommunity/Api/Site/animeunity/film_serie.py b/StreamingCommunity/Api/Site/animeunity/film_serie.py index aea0717..ec10d95 100644 --- a/StreamingCommunity/Api/Site/animeunity/film_serie.py +++ b/StreamingCommunity/Api/Site/animeunity/film_serie.py @@ -2,6 +2,7 @@ import os import logging +from typing import Tuple # Internal utilities @@ -29,7 +30,7 @@ KILL_HANDLER = bool(False) -def download_episode(index_select: int, scrape_serie: ScrapeSerieAnime, video_source: VideoSourceAnime) -> tuple[str,bool]: +def download_episode(index_select: int, scrape_serie: ScrapeSerieAnime, video_source: VideoSourceAnime) -> Tuple[str,bool]: """ Downloads the selected episode. diff --git a/StreamingCommunity/Api/Site/ddlstreamitaly/series.py b/StreamingCommunity/Api/Site/ddlstreamitaly/series.py index 743f636..84098a2 100644 --- a/StreamingCommunity/Api/Site/ddlstreamitaly/series.py +++ b/StreamingCommunity/Api/Site/ddlstreamitaly/series.py @@ -3,6 +3,7 @@ import os import sys from urllib.parse import urlparse +from typing import Tuple # Internal utilities @@ -28,7 +29,7 @@ from .costant import SERIES_FOLDER -def download_video(index_episode_selected: int, scape_info_serie: GetSerieInfo, video_source: VideoSource) -> tuple[str,bool]: +def download_video(index_episode_selected: int, scape_info_serie: GetSerieInfo, video_source: VideoSource) -> Tuple[str,bool]: """ Download a single episode video. diff --git a/StreamingCommunity/Api/Site/guardaserie/series.py b/StreamingCommunity/Api/Site/guardaserie/series.py index 7ce0442..172b5c2 100644 --- a/StreamingCommunity/Api/Site/guardaserie/series.py +++ b/StreamingCommunity/Api/Site/guardaserie/series.py @@ -2,6 +2,7 @@ import os import sys +from typing import Tuple # Internal utilities @@ -26,7 +27,7 @@ from .costant import SERIES_FOLDER -def download_video(index_season_selected: int, index_episode_selected: int, scape_info_serie: GetSerieInfo) -> str: +def download_video(index_season_selected: int, index_episode_selected: int, scape_info_serie: GetSerieInfo) -> Tuple[str,bool]: """ Download a single episode video. @@ -37,6 +38,7 @@ def download_video(index_season_selected: int, index_episode_selected: int, scap Return: - str: output path + - bool: kill handler status """ start_message() index_season_selected = dynamic_format_number(index_season_selected) diff --git a/StreamingCommunity/Api/Site/streamingcommunity/series.py b/StreamingCommunity/Api/Site/streamingcommunity/series.py index e94d962..6db8994 100644 --- a/StreamingCommunity/Api/Site/streamingcommunity/series.py +++ b/StreamingCommunity/Api/Site/streamingcommunity/series.py @@ -2,6 +2,7 @@ import os import sys +from typing import Tuple # Internal utilities @@ -27,7 +28,7 @@ from StreamingCommunity.Api.Player.vixcloud import VideoSource from .costant import SITE_NAME, SERIES_FOLDER, TELEGRAM_BOT -def download_video(index_season_selected: int, index_episode_selected: int, scrape_serie: ScrapeSerie, video_source: VideoSource) -> tuple[str,bool]: +def download_video(index_season_selected: int, index_episode_selected: int, scrape_serie: ScrapeSerie, video_source: VideoSource) -> Tuple[str,bool]: """ Download a single episode video. diff --git a/config.json b/config.json index 11a0a66..0fc83e6 100644 --- a/config.json +++ b/config.json @@ -2,17 +2,17 @@ "DEFAULT": { "debug": false, "log_file": "app.log", - "log_to_file": false, + "log_to_file": true, "show_message": true, "clean_console": true, "root_path": "Video", "movie_folder_name": "Movie", "serie_folder_name": "Serie", "anime_folder_name": "Anime", - "map_episode_name": "S%(season)E%(episode)_%(episode_name)", + "map_episode_name": "E%(episode)_%(episode_name)", "config_qbit_tor": { - "host": "192.168.5.99", - "port": "8080", + "host": "192.168.1.99", + "port": "7060", "user": "admin", "pass": "adminadmin" }, diff --git a/requirements.txt b/requirements.txt index fbf4453..0294b55 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ jsbeautifier pathvalidate pycryptodomex googlesearch-python -fake-useragent +fake-useragent<2.0.0 qbittorrent-api python-qbittorrent Pillow diff --git a/setup.py b/setup.py index abfd3b2..533ee45 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ with open("requirements.txt", "r", encoding="utf-8-sig") as f: setup( name="StreamingCommunity", - version="2.5.2", + version="2.5.6", long_description=read_readme(), long_description_content_type="text/markdown", author="Lovi-0",