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"
|
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 !"
|
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
|
# one line by entrie
|
||||||
#jazz = http://jazz-wr04.ice.infomaniak.ch/jazz-wr04-128.mp3 "Jazz Yeah !"
|
#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] is settings related to user command sent via mumble message.
|
||||||
[commands]
|
[commands]
|
||||||
|
16
media/url.py
16
media/url.py
@ -170,11 +170,19 @@ class URLItem(BaseItem):
|
|||||||
'verbose': var.config.getboolean('debug', 'youtube_dl')
|
'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:
|
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)
|
||||||
download_succeed = False
|
download_succeed = False
|
||||||
for i in range(attempts):
|
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:
|
try:
|
||||||
ydl.extract_info(self.url)
|
ydl.extract_info(self.url)
|
||||||
download_succeed = True
|
download_succeed = True
|
||||||
@ -232,9 +240,9 @@ class URLItem(BaseItem):
|
|||||||
def format_song_string(self, user):
|
def format_song_string(self, user):
|
||||||
if self.ready in ['validated', 'yes']:
|
if self.ready in ['validated', 'yes']:
|
||||||
return tr("url_item",
|
return tr("url_item",
|
||||||
title=self.title if self.title else "??",
|
title=self.title if self.title else "??",
|
||||||
url=self.url,
|
url=self.url,
|
||||||
user=user)
|
user=user)
|
||||||
return self.url
|
return self.url
|
||||||
|
|
||||||
def format_current_playing(self, user):
|
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=""):
|
def get_playlist_info(url, start_index=0, user=""):
|
||||||
items = []
|
items = []
|
||||||
ydl_opts = {
|
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:
|
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):
|
||||||
@ -36,16 +46,16 @@ def get_playlist_info(url, start_index=0, user=""):
|
|||||||
print(info['entries'][j])
|
print(info['entries'][j])
|
||||||
|
|
||||||
music = {
|
music = {
|
||||||
"type": "url_from_playlist",
|
"type": "url_from_playlist",
|
||||||
"url": item_url,
|
"url": item_url,
|
||||||
"title": title,
|
"title": title,
|
||||||
"playlist_url": url,
|
"playlist_url": url,
|
||||||
"playlist_title": playlist_title,
|
"playlist_title": playlist_title,
|
||||||
"user": user
|
"user": user
|
||||||
}
|
}
|
||||||
|
|
||||||
items.append(music)
|
items.append(music)
|
||||||
except:
|
except: # todo need to be specified
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return items
|
return items
|
||||||
@ -82,11 +92,11 @@ class PlaylistURLItem(URLItem):
|
|||||||
self.type = "url_from_playlist"
|
self.type = "url_from_playlist"
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
dict = super().to_dict()
|
tmp_dict = super().to_dict()
|
||||||
dict['playlist_url'] = self.playlist_url
|
tmp_dict['playlist_url'] = self.playlist_url
|
||||||
dict['playlist_title'] = self.playlist_title
|
tmp_dict['playlist_title'] = self.playlist_title
|
||||||
|
|
||||||
return dict
|
return tmp_dict
|
||||||
|
|
||||||
def format_debug_string(self):
|
def format_debug_string(self):
|
||||||
return "[url] {title} ({url}) from playlist {playlist}".format(
|
return "[url] {title} ({url}) from playlist {playlist}".format(
|
||||||
@ -97,11 +107,11 @@ class PlaylistURLItem(URLItem):
|
|||||||
|
|
||||||
def format_song_string(self, user):
|
def format_song_string(self, user):
|
||||||
return tr("url_from_playlist_item",
|
return tr("url_from_playlist_item",
|
||||||
title=self.title,
|
title=self.title,
|
||||||
url=self.url,
|
url=self.url,
|
||||||
playlist_url=self.playlist_url,
|
playlist_url=self.playlist_url,
|
||||||
playlist=self.playlist_title,
|
playlist=self.playlist_title,
|
||||||
user=user)
|
user=user)
|
||||||
|
|
||||||
def format_current_playing(self, user):
|
def format_current_playing(self, user):
|
||||||
display = tr("now_playing", item=self.format_song_string(user))
|
display = tr("now_playing", item=self.format_song_string(user))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user