mirror of
https://github.com/omg-xtao/ytdlbot.git
synced 2024-11-16 03:45:23 +00:00
add IPv6 preference option
This commit is contained in:
parent
a215bcf245
commit
fcb01bd140
@ -99,7 +99,7 @@ vim env/ytdl.env
|
|||||||
you can configure all the following environment variables:
|
you can configure all the following environment variables:
|
||||||
|
|
||||||
* PYRO_WORKERS: number of workers for pyrogram, default is 100
|
* PYRO_WORKERS: number of workers for pyrogram, default is 100
|
||||||
* WORKERS: workers count for celery,it'll be doubled.
|
* WORKERS: workers count for celery
|
||||||
* APP_ID: **REQUIRED**, get it from https://core.telegram.org/
|
* APP_ID: **REQUIRED**, get it from https://core.telegram.org/
|
||||||
* APP_HASH: **REQUIRED**
|
* APP_HASH: **REQUIRED**
|
||||||
* TOKEN: **REQUIRED**
|
* TOKEN: **REQUIRED**
|
||||||
|
@ -6,6 +6,12 @@ services:
|
|||||||
env_file:
|
env_file:
|
||||||
- env/ytdl.env
|
- env/ytdl.env
|
||||||
restart: always
|
restart: always
|
||||||
command: ["/usr/local/bin/supervisord", "-c" ,"/ytdlbot/conf/supervisor_worker.conf"]
|
command: [ "/usr/local/bin/supervisord", "-c" ,"/ytdlbot/conf/supervisor_worker.conf" ]
|
||||||
volumes:
|
volumes:
|
||||||
- ./data/instagram.com_cookies.txt:/ytdlbot/ytdlbot/instagram.com_cookies.txt
|
- ./data/instagram.com_cookies.txt:/ytdlbot/ytdlbot/instagram.com_cookies.txt
|
||||||
|
# network_mode: "host"
|
||||||
|
# deploy:
|
||||||
|
# resources:
|
||||||
|
# limits:
|
||||||
|
# cpus: '0.3'
|
||||||
|
# memory: 1500M
|
@ -197,21 +197,25 @@ def ytdl_download(url, tempdir, bm) -> dict:
|
|||||||
formats = [
|
formats = [
|
||||||
"bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio",
|
"bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio",
|
||||||
"bestvideo[vcodec^=avc]+bestaudio[acodec^=mp4a]/best[vcodec^=avc]/best",
|
"bestvideo[vcodec^=avc]+bestaudio[acodec^=mp4a]/best[vcodec^=avc]/best",
|
||||||
""
|
None
|
||||||
]
|
]
|
||||||
adjust_formats(chat_id, url, formats)
|
adjust_formats(chat_id, url, formats)
|
||||||
add_instagram_cookies(url, ydl_opts)
|
add_instagram_cookies(url, ydl_opts)
|
||||||
for f in formats:
|
|
||||||
if f:
|
address = ["::", "0.0.0.0"] if os.getenv("ipv6") else [None]
|
||||||
ydl_opts["format"] = f
|
|
||||||
|
for format_ in formats:
|
||||||
|
ydl_opts["format"] = format_
|
||||||
|
for addr in address:
|
||||||
|
# IPv6 goes first in each format
|
||||||
|
ydl_opts["source_address"] = addr
|
||||||
try:
|
try:
|
||||||
logging.info("Downloading for %s with format %s", url, f)
|
logging.info("Downloading for %s with format %s", url, format_)
|
||||||
with ytdl.YoutubeDL(ydl_opts) as ydl:
|
with ytdl.YoutubeDL(ydl_opts) as ydl:
|
||||||
ydl.download([url])
|
ydl.download([url])
|
||||||
response["status"] = True
|
response["status"] = True
|
||||||
response["error"] = ""
|
response["error"] = ""
|
||||||
break
|
break
|
||||||
|
|
||||||
except (ValueError, DownloadError) as e:
|
except (ValueError, DownloadError) as e:
|
||||||
logging.error("Download failed for %s ", url)
|
logging.error("Download failed for %s ", url)
|
||||||
response["status"] = False
|
response["status"] = False
|
||||||
|
Loading…
Reference in New Issue
Block a user