diff --git a/README.md b/README.md index 120e9cc..eb6a7e1 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Tv Downloader is een tool om video's van verschillende websites te downloaden. -[![Build Binary](https://github.com/quintenvandamme/tv_downloader/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/quintenvandamme/tv_downloader/actions/workflows/build.yml) +![app](data/screenshots/main.png) ## Ondersteunde websites @@ -25,10 +25,10 @@ Tv Downloader is een tool om video's van verschillende websites te downloaden. ## Installatie -| OS | ARCH | Download | -| -- | ---- | -------- | -| Linux | x86_64 | [tv_downloader-linux-x86_64](https://github.com/quintenvandamme/tv_downloader/releases/download/continious-build/tvdownloader-Linux-x86_64) | -| Linux | x86_64 | [tv_downloader-linux-x86_64.AppImage](https://github.com/quintenvandamme/tv_downloader/releases/download/continious-build/tvdownloader-Linux-x86_64.AppImage) | +| OS | ARCH | Download | Build Status | +| -- | ---- | -------- | ------------ | +| Linux | x86_64 | [tv_downloader-linux-x86_64](https://github.com/quintenvandamme/tv_downloader/releases/download/continious-build/tvdownloader-Linux-x86_64) | [![Build Binary](https://github.com/quintenvandamme/tv_downloader/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/quintenvandamme/tv_downloader/actions/workflows/build.yml) | +| Linux | x86_64 | [tv_downloader-linux-x86_64.AppImage](https://github.com/quintenvandamme/tv_downloader/releases/download/continious-build/tvdownloader-Linux-x86_64.AppImage) | [![Build Binary](https://github.com/quintenvandamme/tv_downloader/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/quintenvandamme/tv_downloader/actions/workflows/build.yml) | ## Bouwen diff --git a/build.py b/build.py index 1ce6f42..3dacae9 100644 --- a/build.py +++ b/build.py @@ -4,6 +4,9 @@ OS = sys.platform ARCH = os.uname().machine +def _print_stage(message): + print(f"\033[44m=> {message}\033[0m") + def _run_command(command): os.system(command) @@ -13,7 +16,7 @@ def _createDir(directory): def _get_7z(): _run_command("winget install -e --id 7zip.7zip --accept-source-agreements --accept-package-agreements") - print("=> Installed 7z") + _print_stage("Installed 7z") def _get_ffmpeg(): FFMPEG_ARCH = "" @@ -24,7 +27,7 @@ def _get_ffmpeg(): FFMPEG_ARCH = "arm64" if FFMPEG_ARCH == "": - print("=> Unsupported architecture") + _print_stage("Unsupported architecture") exit(1) if OS == "linux": @@ -39,14 +42,14 @@ def _get_ffmpeg(): _run_command(f'7z.exe x ffmpeg.7z -oout/ffmpeg.exe bin/ffmpeg.exe -r') _run_command(f'del ffmpeg.7z') - print("=> Downloaded ffmpeg") + _print_stage("Downloaded ffmpeg") def install_dependencies(): print("=> Installing dependencies...") _run_command("pip install -r requirements.txt --break-system-packages") def clean(): - print("=> Cleaning up...") + _print_stage("Cleaning up...") if OS == "linux": _run_command("rm -rf dist/ build/ out/ tvdownloader.spec") @@ -55,7 +58,7 @@ def clean(): _run_command("del tvdownloader.spec") def build_appimage(): - print("=> Building AppImage for {OS}-{ARCH}...") + _print_stage(f"Building AppImage for {OS}-{ARCH}...") _run_command(f'curl -L https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-{ARCH}.AppImage -o appimagetool.AppImage') _run_command('chmod +x appimagetool.AppImage') _createDir('out/appimage.AppDir/usr/bin') @@ -66,12 +69,12 @@ def build_appimage(): _run_command('chmod +x out/appimage.AppDir/tvdownloader.desktop') _run_command(f'ARCH={ARCH} ./appimagetool.AppImage out/appimage.AppDir out/tvdownloader-{OS}-{ARCH}.AppImage') _run_command('rm -rf out/appimage.AppDir appimagetool.AppImage') - print(f"=> Built out/tvdownloader-{OS}-{ARCH}.AppImage") + _print_stage(f"Built out/tvdownloader-{OS}-{ARCH}.AppImage") def build(): clean() install_dependencies() - print(f"=> Building TV Downloader for {OS}-{ARCH}...") + _print_stage(f"Building TV Downloader for {OS}-{ARCH}...") _createDir("out") _get_ffmpeg() @@ -80,7 +83,7 @@ def build(): _run_command(f'mv dist/tvdownloader out/tvdownloader-{OS}-{ARCH}') _run_command('rm -rf dist/ build/ tvdownloader.spec ./out/ffmpeg') _run_command(f'chmod +x out/tvdownloader-{OS}-{ARCH}') - print(f"=> Built out/tvdownloader-{OS}-{ARCH}") + _print_stage(f"Built out/tvdownloader-{OS}-{ARCH}") build_appimage() elif OS == "win32": pass @@ -88,7 +91,7 @@ def build(): def main(): args = sys.argv[1:] if len(args) == 0: - print("=> Usage: python build.py [build|clean]") + _print_stage("Usage: python build.py [build|clean]") exit(1) elif args[0] == "build": build() @@ -97,4 +100,4 @@ def main(): if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/data/screenshots/main.png b/data/screenshots/main.png new file mode 100644 index 0000000..98bdf24 Binary files /dev/null and b/data/screenshots/main.png differ diff --git a/gui/get_videos/vrtnws.py b/gui/get_videos/vrtnws.py index d644739..70a4a39 100644 --- a/gui/get_videos/vrtnws.py +++ b/gui/get_videos/vrtnws.py @@ -1,6 +1,5 @@ from .util import get_request, Video, unixTimeToDatetime, print_error from .vrtmax import get_vrtmax_token -from .constants import * def get_streamUrlAndThumbnail(videoId, pubId, vrtmaxToken,guiParent): url = 'https://media-services-public.vrt.be/media-aggregator/v2/media-items/' + pubId + '$' + videoId + '?vrtPlayerToken=' + vrtmaxToken + '&client=vrtnieuws' diff --git a/gui/settings/settings.py b/gui/settings/settings.py index afb4138..f4fd064 100644 --- a/gui/settings/settings.py +++ b/gui/settings/settings.py @@ -2,10 +2,8 @@ import os import sys -def resource_path(relative_path): - if hasattr(sys, '_MEIPASS'): - return os.path.join(sys._MEIPASS, relative_path) - return relative_path +settings_file_dir = os.path.join(os.path.expanduser('~'), '.config', 'tvdownloader') +settings_file_path = os.path.join(settings_file_dir, 'settings.ini') class Settings: def __init__(self): @@ -15,31 +13,43 @@ def __init__(self): def _create(self): # Create the settings file if it doesn't exist - if not os.path.exists(resource_path('data/settings/settings.ini')): + + if not os.path.exists(settings_file_path): self.config['Settings'] = { 'download_path': os.path.expanduser('~') } # create the directory data/settings if it doesn't exist - if not os.path.exists(resource_path('data/settings')): - os.makedirs(resource_path('data/settings')) + if not os.path.exists(settings_file_dir): + os.makedirs(settings_file_dir) - with open(resource_path('data/settings/settings.ini'), 'w') as configfile: + with open(settings_file_path, 'w') as configfile: self.config.write(configfile) return True def _read(self): - self.config.read(resource_path('data/settings/settings.ini')) + self.config.read(settings_file_path) def get(self, section, key): self._read() if not self.config.has_section(section): - return None + self.set(section, key, '') + return '' else: - return self.config[section][key] + if self.config[section].get(key) is None: + self.set(section, key, '') + return '' + else: + return self.config[section][key] def set(self, section, key, value): + if not self.config.has_section(section): + self.config.add_section(section) + + if not self.config.has_option(section, key): + self.config.set(section, key, value) + self.config[section][key] = value - with open(resource_path('data/settings/settings.ini'), 'w') as configfile: + with open(settings_file_path, 'w') as configfile: self.config.write(configfile) \ No newline at end of file