Merge pull request #78 from arabcoders/dev

consider is_upcoming as live event to prevent error spamming
This commit is contained in:
Abdulmohsen 2024-03-16 01:26:31 +03:00 committed by GitHub
commit 88ee6bec45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 28 additions and 14 deletions

16
Pipfile
View file

@ -4,15 +4,15 @@ verify_ssl = true
name = "pypi"
[packages]
python-socketio = "~=5.0"
aiohttp = "*"
python-socketio = ">=5.11.1"
aiohttp = ">=3.9.3"
yt-dlp = "*"
caribou = "*"
coloredlogs = "*"
aiocron = "*"
python-dotenv = "*"
python-magic = "*"
debugpy = "*"
caribou = ">=0.3.0"
coloredlogs = ">=15.0.1"
aiocron = ">=1.8"
python-dotenv = ">=1.0.1"
python-magic = ">=0.4.27"
debugpy = ">=1.8.1"
[dev-packages]

2
Pipfile.lock generated
View file

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "969599ea205de43f64d64331fc3307bb0d9be1dc1830c57b51f93c607d2bbe1f"
"sha256": "6f7d266189a02316b0a7f6d1958351963de5dfa35b6e3860c1da5da875629843"
},
"pipfile-spec": 6,
"requires": {

View file

@ -9,6 +9,7 @@ import yt_dlp
from Utils import Notifier, get_format, get_opts, jsonCookie, mergeConfig
from ItemDTO import ItemDTO
from Config import Config
import hashlib
LOG = logging.getLogger('download')
@ -33,6 +34,8 @@ class Download:
notifier: Notifier = None
canceled: bool = False
is_live: bool = False
info_dict: dict = None
"yt-dlp metadata dict."
bad_live_options: list = [
"concurrent_fragment_downloads",
@ -64,6 +67,7 @@ class Download:
temp_dir: str,
output_template_chapter: str,
default_ytdl_opts: dict,
info_dict: dict = None,
debug: bool = False
):
self.download_dir = download_dir
@ -87,6 +91,7 @@ class Download:
self.tempKeep = bool(Config.get_instance().temp_keep)
self.is_live = bool(info.is_live) or info.live_in is not None
self.is_manifestless = 'is_manifestless' in self.info.options and self.info.options['is_manifestless'] is True
self.info_dict = info_dict
def _progress_hook(self, data: dict):
dataDict = {k: v for k, v in data.items() if k in self._ytdlp_fields}
@ -163,7 +168,15 @@ class Download:
LOG.info(f'Downloading {os.getpid()=} id="{self.info.id}" title="{self.info.title}".')
ret = yt_dlp.YoutubeDL(params=params).download([self.info.url])
cls = yt_dlp.YoutubeDL(params=params)
if isinstance(self.info_dict, dict) and len(self.info_dict) > 1:
LOG.debug(f'Downloading using pre-info.')
cls.process_ie_result(self.info_dict, download=True)
ret = cls._download_retcode
else:
LOG.debug(f'Downloading using url: {self.info.url}')
ret = cls.download([self.info.url])
self.status_queue.put({'id': self.id, 'status': 'finished' if ret == 0 else 'error'})
except Exception as exc:

View file

@ -134,7 +134,7 @@ class DownloadQueue:
output_template=output_template if output_template else self.config.output_template,
datetime=formatdate(time.time()),
error=error,
is_live=entry.get('is_live', None) or 'is_live' == entry.get('live_status', None) or live_in,
is_live=entry.get('is_live', None) or entry.get('live_status', None) in ['is_live', 'is_upcoming'] or live_in,
live_in=live_in,
options=options
)
@ -157,10 +157,11 @@ class DownloadQueue:
temp_dir=self.config.temp_path,
output_template_chapter=output_chapter,
default_ytdl_opts=self.config.ytdl_options,
info_dict=entry,
debug=bool(self.config.ytdl_debug)
)
if dlInfo.info.live_in:
if dlInfo.info.live_in or 'is_upcoming' == entry.get('live_status',None):
dlInfo.info.status = 'not_live'
itemDownload = self.done.put(dlInfo)
NotifyEvent = 'completed'

View file

@ -77,7 +77,7 @@
<div class="columns is-multiline">
<div class="column is-6" v-for="item in sortCompleted" :key="item._id">
<div class="card" :class="{ 'is-bordered-danger': item.status === 'error', 'is-bordered-info': item.live_in }">
<div class="card" :class="{ 'is-bordered-danger': item.status === 'error', 'is-bordered-info': item.live_in || item.is_live }">
<header class="card-header has-tooltip" v-tooltip="item.title">
<div class="card-header-title has-text-centered is-text-overflow is-block">
<a v-if="item.filename" referrerpolicy="no-referrer" :href="makeDownload(config, item, 'm3u8')"
@ -101,7 +101,7 @@
<span class="has-text-danger">{{ item.msg }}</span>
</div>
<div class="column is-half-mobile has-text-centered">
<span v-if="!item.live_in">
<span v-if="!item.live_in && !item.is_live">
<span class="icon-text">
<span class="icon"
:class="{ 'has-text-success': item.status === 'finished', 'has-text-danger': item.status !== 'finished' }">