mirror of https://github.com/devine-dl/devine.git
Add ability to choose downloader via config
This commit is contained in:
parent
b92708ef45
commit
cb82febb7c
|
@ -128,6 +128,15 @@ AMZN:
|
|||
bitrate: CVBR
|
||||
```
|
||||
|
||||
## downloader (str)
|
||||
|
||||
Choose what software to use to download data throughout Devine where needed.
|
||||
|
||||
Options:
|
||||
|
||||
- `aria2c` (default) - https://github.com/aria2/aria2
|
||||
- `saldl` - https://github.com/saldl/saldl
|
||||
|
||||
## headers (dict)
|
||||
|
||||
Case-Insensitive dictionary of headers that all Services begin their Request Session state with.
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import html
|
||||
import logging
|
||||
import math
|
||||
|
@ -43,7 +42,7 @@ from devine.core.config import config
|
|||
from devine.core.console import console
|
||||
from devine.core.constants import AnyTrack, context_settings
|
||||
from devine.core.credential import Credential
|
||||
from devine.core.downloaders import aria2c
|
||||
from devine.core.downloaders import downloader
|
||||
from devine.core.drm import DRM_T, Widevine
|
||||
from devine.core.manifests import DASH, HLS
|
||||
from devine.core.proxies import Basic, Hola, NordVPN
|
||||
|
@ -906,13 +905,13 @@ class dl:
|
|||
if self.DL_POOL_SKIP.is_set():
|
||||
progress(downloaded="[yellow]SKIPPED")
|
||||
else:
|
||||
asyncio.run(aria2c(
|
||||
downloader(
|
||||
uri=track.url,
|
||||
out=save_path,
|
||||
headers=service.session.headers,
|
||||
proxy=proxy if track.needs_proxy else None,
|
||||
progress=progress
|
||||
))
|
||||
)
|
||||
|
||||
track.path = save_path
|
||||
|
||||
|
|
|
@ -49,6 +49,8 @@ class Config:
|
|||
continue
|
||||
setattr(self.directories, name, Path(path).expanduser())
|
||||
|
||||
self.downloader = kwargs.get("downloader") or "aria2c"
|
||||
|
||||
self.filenames = self._Filenames()
|
||||
for name, filename in (kwargs.get("filenames") or {}).items():
|
||||
setattr(self.filenames, name, filename)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from .aria2c import aria2c
|
||||
from .saldl import saldl
|
||||
from .downloader import downloader
|
||||
|
||||
__ALL__ = (aria2c, saldl)
|
||||
__ALL__ = (downloader, aria2c, saldl)
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
import asyncio
|
||||
from functools import partial
|
||||
|
||||
from devine.core.config import config
|
||||
from devine.core.downloaders import aria2c, saldl
|
||||
|
||||
|
||||
downloader = {
|
||||
"aria2c": partial(asyncio.run, aria2c),
|
||||
"saldl": partial(asyncio.run, saldl)
|
||||
}[config.downloader]
|
|
@ -1,6 +1,5 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import base64
|
||||
import logging
|
||||
import math
|
||||
|
@ -26,7 +25,7 @@ from requests import Session
|
|||
from rich import filesize
|
||||
|
||||
from devine.core.constants import AnyTrack
|
||||
from devine.core.downloaders import aria2c
|
||||
from devine.core.downloaders import downloader
|
||||
from devine.core.drm import Widevine
|
||||
from devine.core.tracks import Audio, Subtitle, Tracks, Video
|
||||
from devine.core.utilities import is_close_match
|
||||
|
@ -487,14 +486,14 @@ class DASH:
|
|||
segment_save_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
segment_save_path.write_bytes(res.content)
|
||||
else:
|
||||
asyncio.run(aria2c(
|
||||
downloader(
|
||||
uri=segment_uri,
|
||||
out=segment_save_path,
|
||||
headers=session.headers,
|
||||
proxy=proxy,
|
||||
silent=attempts != 5,
|
||||
segmented=True
|
||||
))
|
||||
)
|
||||
break
|
||||
except Exception as ee:
|
||||
if stop_event.is_set() or attempts == 5:
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import re
|
||||
import sys
|
||||
|
@ -24,7 +23,7 @@ from requests import Session
|
|||
from rich import filesize
|
||||
|
||||
from devine.core.constants import AnyTrack
|
||||
from devine.core.downloaders import aria2c
|
||||
from devine.core.downloaders import downloader
|
||||
from devine.core.drm import DRM_T, ClearKey, Widevine
|
||||
from devine.core.tracks import Audio, Subtitle, Tracks, Video
|
||||
from devine.core.utilities import is_close_match
|
||||
|
@ -308,14 +307,14 @@ class HLS:
|
|||
segment_save_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
segment_save_path.write_bytes(res.content)
|
||||
else:
|
||||
asyncio.run(aria2c(
|
||||
downloader(
|
||||
uri=segment.uri,
|
||||
out=segment_save_path,
|
||||
headers=session.headers,
|
||||
proxy=proxy,
|
||||
silent=attempts != 5,
|
||||
segmented=True
|
||||
))
|
||||
)
|
||||
break
|
||||
except Exception as ee:
|
||||
if stop_event.is_set() or attempts == 5:
|
||||
|
|
Loading…
Reference in New Issue