diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 71dbf59..58a7686 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,21 +10,13 @@ on: jobs: Linux: - outputs: - version: ${{ steps.version.outputs.VERSION }} - runs-on: ubuntu-latest - env: - version: ${{ outputs.version }} - + steps: - - id: version - run: echo "::set-output name=VERSION::$(cat AV_Data_Capture.py | grep "version = " | tr -d "version = '")" - - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v1 + - name: Setup Python 3.8 + uses: actions/setup-python@v2 with: python-version: 3.8 @@ -37,11 +29,17 @@ jobs: run: | python number_parser.py -v + - name: Set VERSION variable + run: | + version=$(python -c 'import AV_Data_Capture; print(AV_Data_Capture.__version__)') + echo "::set-env name=VERSION::$version" + - name: Set CLOUDSCRAPER_PATH variable run: | - echo "::set-env name=CLOUDSCRAPER_PATH::$(python -c 'import cloudscraper as _; print(_.__path__[0])' | tail -n 1)" + cloudscraper_path=$(python -c 'import cloudscraper as _; print(_.__path__[0])' | tail -n 1) + echo "::set-env name=CLOUDSCRAPER_PATH::$cloudscraper_path" - - name: Build with pyinstaller + - name: Build with PyInstaller run: | pyinstaller \ --onefile AV_Data_Capture.py \ @@ -56,19 +54,17 @@ jobs: - name: Upload build artifact uses: actions/upload-artifact@v1 with: - name: AV_Data_Capture-CLI-${{ env.version }}-Linux + name: AV_Data_Capture-CLI-${{ env.VERSION }}-Linux path: dist - Windows: runs-on: windows-latest - needs: Linux steps: - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v1 + - name: Setup Python 3.8 + uses: actions/setup-python@v2 with: python-version: 3.8 @@ -81,11 +77,17 @@ jobs: run: | python number_parser.py -v + - name: Set VERSION variable + run: | + $env:version=$(python -c 'import AV_Data_Capture; print(AV_Data_Capture.__version__)') + echo "::set-env name=VERSION::$env:version" + - name: Set CLOUDSCRAPER_PATH variable run: | - echo "::set-env name=CLOUDSCRAPER_PATH::$(python -c 'import cloudscraper as _; print(_.__path__[0])' | tail -n 1)" + $env:cloudscraper_path=$(python -c 'import cloudscraper as _; print(_.__path__[0])' | select -Last 1) + echo "::set-env name=CLOUDSCRAPER_PATH::$env:cloudscraper_path" - - name: Build with pyinstaller + - name: Build with PyInstaller run: | pyinstaller ` --onefile AV_Data_Capture.py ` @@ -100,19 +102,17 @@ jobs: - name: Upload build artifact uses: actions/upload-artifact@v1 with: - name: AV_Data_Capture-CLI-${{ needs.Linux.env.version }}-Windows + name: AV_Data_Capture-CLI-${{ env.VERSION }}-Windows path: dist - MacOS: - needs: Linux runs-on: macos-latest steps: - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v1 + - name: Setup Python 3.8 + uses: actions/setup-python@v2 with: python-version: 3.8 @@ -125,11 +125,17 @@ jobs: run: | python number_parser.py -v + - name: Set VERSION variable + run: | + version=$(python -c 'import AV_Data_Capture; print(AV_Data_Capture.__version__)') + echo "::set-env name=VERSION::$version" + - name: Set CLOUDSCRAPER_PATH variable run: | - echo "::set-env name=CLOUDSCRAPER_PATH::$(python -c 'import cloudscraper as _; print(_.__path__[0])' | tail -n 1)" + cloudscraper_path=$(python -c 'import cloudscraper as _; print(_.__path__[0])' | tail -n 1) + echo "::set-env name=CLOUDSCRAPER_PATH::$cloudscraper_path" - - name: Build with pyinstaller + - name: Build with PyInstaller run: | pyinstaller \ --onefile AV_Data_Capture.py \ @@ -144,5 +150,5 @@ jobs: - name: Upload build artifact uses: actions/upload-artifact@v1 with: - name: AV_Data_Capture-CLI-${{ needs.Linux.env.version }}-MacOS + name: AV_Data_Capture-CLI-${{ env.VERSION }}-MacOS path: dist diff --git a/ADC_function.py b/ADC_function.py index df10283..30a3249 100755 --- a/ADC_function.py +++ b/ADC_function.py @@ -59,6 +59,8 @@ def get_html(url, cookies: dict = None, ua: str = None, return_type: str = None) if return_type == "object": return result + elif return_type == "json": + return result.json() else: return result.text diff --git a/AV_Data_Capture.py b/AV_Data_Capture.py index 9c727c7..1102495 100755 --- a/AV_Data_Capture.py +++ b/AV_Data_Capture.py @@ -3,15 +3,14 @@ from core import * import os from number_parser import get_number +__version__ = '3.7.1' -def check_update(local_version): - data = json.loads(get_html("https://api.github.com/repos/yoshiko2/AV_Data_Capture/releases/latest")) +def check_update(): + latest = get_html("https://api.github.com/repos/yoshiko2/AV_Data_Capture/releases/latest", + return_type="json")["tag_name"] - remote = data["tag_name"] - local = local_version - - if not local == remote: - line1 = "* New update " + str(remote) + " *" + if __version__ != latest: + line1 = "* New update " + str(latest) + " *" print("[*]" + line1.center(54)) print("[*]" + "↓ Download ↓".center(54)) print("[*] https://github.com/yoshiko2/AV_Data_Capture/releases") @@ -111,7 +110,6 @@ def create_data_and_move_with_custom_number(file_path: str, c: config.Config, cu if __name__ == '__main__': - version = '3.7.1' # Parse command line args single_file_path, config_file, auto_exit, custom_number = argparse_function() @@ -119,13 +117,13 @@ if __name__ == '__main__': # Read config.ini conf = config.Config(path=config_file) - version_print = 'Version ' + version + version_print = 'Version ' + __version__ print('[*]================== AV Data Capture ===================') print('[*]' + version_print.center(54)) print('[*]======================================================') if conf.update_check(): - check_update(version) + check_update() create_failed_folder(conf.failed_folder()) os.chdir(os.getcwd()) diff --git a/py_to_exe.bat b/py_to_exe.bat index 8704b6a..8255d40 100644 --- a/py_to_exe.bat +++ b/py_to_exe.bat @@ -1,4 +1,4 @@ -pyinstaller --onefile AV_Data_Capture.py --hidden-import ADC_function.py --hidden-import core.py +pyinstaller --onefile AV_Data_Capture.py --hidden-import ADC_function.py --hidden-import core.py rmdir /s/q build rmdir /s/q __pycache__ pause \ No newline at end of file diff --git a/update_check.json b/update_check.json index 0e0b8b3..bb11061 100644 --- a/update_check.json +++ b/update_check.json @@ -1,5 +1,5 @@ { -. "version": "3.7.1", + "version": "3.7.1", "version_show": "3.7.1", "download": "https://github.com/yoshiko2/AV_Data_Capture/releases" }