parent
582b0b58da
commit
ee5a54b33b
@ -123,7 +123,10 @@ luna = http://radio.ponyvillelive.com:8002/stream "calm and orchestra music"
|
||||
radiobrony = http://62.210.138.34:8000/live "Brony music of a friend"
|
||||
jazz = http://jazz-wr04.ice.infomaniak.ch/jazz-wr04-128.mp3 "Jazz Yeah !"
|
||||
|
||||
|
||||
[youtube_dl]
|
||||
source_address =
|
||||
cookiefile =
|
||||
user_agent =
|
||||
|
||||
|
||||
|
||||
|
@ -168,6 +168,14 @@ port = 64738
|
||||
# one line by entrie
|
||||
#jazz = http://jazz-wr04.ice.infomaniak.ch/jazz-wr04-128.mp3 "Jazz Yeah !"
|
||||
|
||||
# [youtube_dl] are option to custom youtube-dl (optionnal)
|
||||
[youtube_dl]
|
||||
# source_address , use '::' to force ipv6, "0.0.0.0" to force ipv4, or put the ip addresse you want to use.
|
||||
# source_address = '::'
|
||||
# cookiefile , path of the cookie file (usefull if you reach youtube limits https://github.com/ytdl-org/youtube-dl#http-error-429-too-many-requests-or-402-payment-required)
|
||||
# cookiefile = '/tmp/cooke_ydl'
|
||||
# user-agent allow the user to force the user-agent of youtube-dl
|
||||
# user-agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0"
|
||||
|
||||
# [commands] is settings related to user command sent via mumble message.
|
||||
[commands]
|
||||
|
16
media/url.py
16
media/url.py
@ -170,11 +170,19 @@ class URLItem(BaseItem):
|
||||
'verbose': var.config.getboolean('debug', 'youtube_dl')
|
||||
}
|
||||
|
||||
cookie = var.config.get('youtube_dl', 'cookiefile', fallback=None)
|
||||
if cookie:
|
||||
ydl_opts['cookiefile'] = var.config.get('youtube_dl', 'cookiefile', fallback=None)
|
||||
|
||||
user_agent = var.config.get('youtube_dl', 'user_agent', fallback=None)
|
||||
if user_agent:
|
||||
youtube_dl.utils.std_headers['User-Agent'] = var.config.get('youtube_dl', 'user_agent')
|
||||
|
||||
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
||||
attempts = var.config.getint('bot', 'download_attempts', fallback=2)
|
||||
download_succeed = False
|
||||
for i in range(attempts):
|
||||
self.log.info("bot: download attempts %d / %d" % (i+1, attempts))
|
||||
self.log.info("bot: download attempts %d / %d" % (i + 1, attempts))
|
||||
try:
|
||||
ydl.extract_info(self.url)
|
||||
download_succeed = True
|
||||
@ -232,9 +240,9 @@ class URLItem(BaseItem):
|
||||
def format_song_string(self, user):
|
||||
if self.ready in ['validated', 'yes']:
|
||||
return tr("url_item",
|
||||
title=self.title if self.title else "??",
|
||||
url=self.url,
|
||||
user=user)
|
||||
title=self.title if self.title else "??",
|
||||
url=self.url,
|
||||
user=user)
|
||||
return self.url
|
||||
|
||||
def format_current_playing(self, user):
|
||||
|
@ -8,8 +8,18 @@ from media.url import URLItem, url_item_id_generator
|
||||
def get_playlist_info(url, start_index=0, user=""):
|
||||
items = []
|
||||
ydl_opts = {
|
||||
'extract_flat': 'in_playlist'
|
||||
'extract_flat': 'in_playlist',
|
||||
'verbose': var.config.getboolean('debug', 'youtube_dl')
|
||||
}
|
||||
|
||||
cookie = var.config.get('youtube_dl', 'cookiefile', fallback=None)
|
||||
if cookie:
|
||||
ydl_opts['cookiefile'] = var.config.get('youtube_dl', 'cookiefile', fallback=None)
|
||||
|
||||
user_agent = var.config.get('youtube_dl', 'user_agent', fallback=None)
|
||||
if user_agent:
|
||||
youtube_dl.utils.std_headers['User-Agent'] = var.config.get('youtube_dl', 'user_agent')
|
||||
|
||||
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
||||
attempts = var.config.getint('bot', 'download_attempts', fallback=2)
|
||||
for i in range(attempts):
|
||||
@ -36,16 +46,16 @@ def get_playlist_info(url, start_index=0, user=""):
|
||||
print(info['entries'][j])
|
||||
|
||||
music = {
|
||||
"type": "url_from_playlist",
|
||||
"url": item_url,
|
||||
"title": title,
|
||||
"playlist_url": url,
|
||||
"playlist_title": playlist_title,
|
||||
"user": user
|
||||
"type": "url_from_playlist",
|
||||
"url": item_url,
|
||||
"title": title,
|
||||
"playlist_url": url,
|
||||
"playlist_title": playlist_title,
|
||||
"user": user
|
||||
}
|
||||
|
||||
items.append(music)
|
||||
except:
|
||||
except: # todo need to be specified
|
||||
pass
|
||||
|
||||
return items
|
||||
@ -82,11 +92,11 @@ class PlaylistURLItem(URLItem):
|
||||
self.type = "url_from_playlist"
|
||||
|
||||
def to_dict(self):
|
||||
dict = super().to_dict()
|
||||
dict['playlist_url'] = self.playlist_url
|
||||
dict['playlist_title'] = self.playlist_title
|
||||
tmp_dict = super().to_dict()
|
||||
tmp_dict['playlist_url'] = self.playlist_url
|
||||
tmp_dict['playlist_title'] = self.playlist_title
|
||||
|
||||
return dict
|
||||
return tmp_dict
|
||||
|
||||
def format_debug_string(self):
|
||||
return "[url] {title} ({url}) from playlist {playlist}".format(
|
||||
@ -97,11 +107,11 @@ class PlaylistURLItem(URLItem):
|
||||
|
||||
def format_song_string(self, user):
|
||||
return tr("url_from_playlist_item",
|
||||
title=self.title,
|
||||
url=self.url,
|
||||
playlist_url=self.playlist_url,
|
||||
playlist=self.playlist_title,
|
||||
user=user)
|
||||
title=self.title,
|
||||
url=self.url,
|
||||
playlist_url=self.playlist_url,
|
||||
playlist=self.playlist_title,
|
||||
user=user)
|
||||
|
||||
def format_current_playing(self, user):
|
||||
display = tr("now_playing", item=self.format_song_string(user))
|
||||
|
Loading…
x
Reference in New Issue
Block a user