Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #366 from Eswcvlad/master
Browse files Browse the repository at this point in the history
Fix YouTube package update logic
  • Loading branch information
azlux authored Jul 3, 2023
2 parents bb179eb + 8c9bfd0 commit 9f032c3
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
import re
import subprocess as sp
import logging
import yt_dlp as youtube_dl
from importlib import reload
from sys import platform
import traceback
import requests
from packaging import version

import yt_dlp as youtube_dl
YT_PKG_NAME = 'yt-dlp'

log = logging.getLogger("bot")


Expand Down Expand Up @@ -137,7 +139,7 @@ def update(current_version):
new_version = new_release_version(target)
msg = ""
if target == "git":
msg = "git install, I do nothing"
msg = "git install, I do nothing<br/>"

elif (target == "stable" and version.parse(new_version) > version.parse(current_version)) or \
(target == "testing" and version.parse(new_version) != version.parse(current_version)):
Expand All @@ -146,17 +148,17 @@ def update(current_version):
log.debug(tp)
log.info('update: update pip libraries dependencies')
sp.check_output([var.config.get('bot', 'pip3_path'), 'install', '--upgrade', '-r', 'requirements.txt']).decode()
msg = "New version installed, please restart the bot."
msg = "New version installed, please restart the bot.<br/>"

log.info('update: starting update youtube-dl via pip3')
tp = sp.check_output([var.config.get('bot', 'pip3_path'), 'install', '--upgrade', 'youtube-dl']).decode()
if "Requirement already up-to-date" in tp:
msg += "Youtube-dl is up-to-date"
else:
log.info(f'update: starting update {YT_PKG_NAME} via pip3')
tp = sp.check_output([var.config.get('bot', 'pip3_path'), 'install', '--upgrade', YT_PKG_NAME]).decode()
if f"Collecting {YT_PKG_NAME}" in tp.splitlines():
msg += "Update done: " + tp.split('Successfully installed')[1]
else:
msg += YT_PKG_NAME.capitalize() + " is up-to-date"

reload(youtube_dl)
msg += "<br/> Youtube-dl reloaded"
msg += "<br/>" + YT_PKG_NAME.capitalize() + " reloaded"
return msg


Expand Down

0 comments on commit 9f032c3

Please sign in to comment.