Skip to content

Commit

Permalink
chore: Update Tv Downloader README and settings.py
Browse files Browse the repository at this point in the history
  • Loading branch information
quintenvandamme committed May 3, 2024
1 parent fddd272 commit f5c4ffd
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 28 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
23 changes: 13 additions & 10 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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 = ""
Expand All @@ -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":
Expand All @@ -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")
Expand All @@ -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')
Expand All @@ -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()

Expand All @@ -80,15 +83,15 @@ 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

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()
Expand All @@ -97,4 +100,4 @@ def main():


if __name__ == "__main__":
main()
main()
Binary file added data/screenshots/main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion gui/get_videos/vrtnws.py
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
34 changes: 22 additions & 12 deletions gui/settings/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)

0 comments on commit f5c4ffd

Please sign in to comment.