mirror of
https://github.com/azlux/botamusique
synced 2024-11-23 22:06:09 +00:00
Compare commits
No commits in common. "1c283654fda42cd9ea00716f2b8cfe9bada77a5e" and "f9cc9c78722db8b16375ff34ed097cb70025bb47" have entirely different histories.
1c283654fd
...
f9cc9c7872
@ -1,4 +1,3 @@
|
|||||||
import logging
|
|
||||||
import youtube_dl
|
import youtube_dl
|
||||||
from constants import tr_cli as tr
|
from constants import tr_cli as tr
|
||||||
import variables as var
|
import variables as var
|
||||||
@ -6,10 +5,8 @@ from media.item import item_builders, item_loaders, item_id_generators
|
|||||||
from media.url import URLItem, url_item_id_generator
|
from media.url import URLItem, url_item_id_generator
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger("bot")
|
|
||||||
|
|
||||||
|
|
||||||
def get_playlist_info(url, start_index=0, user=""):
|
def get_playlist_info(url, start_index=0, user=""):
|
||||||
|
items = []
|
||||||
ydl_opts = {
|
ydl_opts = {
|
||||||
'extract_flat': 'in_playlist',
|
'extract_flat': 'in_playlist',
|
||||||
'verbose': var.config.getboolean('debug', 'youtube_dl')
|
'verbose': var.config.getboolean('debug', 'youtube_dl')
|
||||||
@ -26,7 +23,6 @@ def get_playlist_info(url, start_index=0, user=""):
|
|||||||
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
||||||
attempts = var.config.getint('bot', 'download_attempts', fallback=2)
|
attempts = var.config.getint('bot', 'download_attempts', fallback=2)
|
||||||
for i in range(attempts):
|
for i in range(attempts):
|
||||||
items = []
|
|
||||||
try:
|
try:
|
||||||
info = ydl.extract_info(url, download=False)
|
info = ydl.extract_info(url, download=False)
|
||||||
# # if url is not a playlist but a video
|
# # if url is not a playlist but a video
|
||||||
@ -59,12 +55,10 @@ def get_playlist_info(url, start_index=0, user=""):
|
|||||||
}
|
}
|
||||||
|
|
||||||
items.append(music)
|
items.append(music)
|
||||||
|
except: # todo need to be specified
|
||||||
|
pass
|
||||||
|
|
||||||
except Exception as ex:
|
return items
|
||||||
log.exception(ex, exc_info=True)
|
|
||||||
continue
|
|
||||||
|
|
||||||
return items
|
|
||||||
|
|
||||||
|
|
||||||
def playlist_url_item_builder(**kwargs):
|
def playlist_url_item_builder(**kwargs):
|
||||||
|
4
util.py
4
util.py
@ -2,7 +2,6 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import html
|
|
||||||
import magic
|
import magic
|
||||||
import os
|
import os
|
||||||
import io
|
import io
|
||||||
@ -312,8 +311,7 @@ def get_url_from_input(string):
|
|||||||
match = re.search("(http|https)://(\S*)?/(\S*)", string, flags=re.IGNORECASE)
|
match = re.search("(http|https)://(\S*)?/(\S*)", string, flags=re.IGNORECASE)
|
||||||
if match:
|
if match:
|
||||||
url = match[1].lower() + "://" + match[2].lower() + "/" + match[3]
|
url = match[1].lower() + "://" + match[2].lower() + "/" + match[3]
|
||||||
# https://github.com/mumble-voip/mumble/issues/4999
|
return url
|
||||||
return html.unescape(url)
|
|
||||||
else:
|
else:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user