matrix-music-bot

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 4858ccd898ebe40bc0da1672c2349176b9ca5137
parent 7ae3b1bb86e81e7239c6aeb42bc2a500d63a7bb7
Author: John Kubach <johnkubach@gmail.com>
Date:   Sat, 15 Aug 2020 09:28:58 -0400

Fetch Description

- Grab video description if artist cannot be parsed from title.

Diffstat:
Mfunctions/extract_info.py | 5+++--
Mmusic.py | 6++++--
2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/functions/extract_info.py b/functions/extract_info.py @@ -3,14 +3,15 @@ import pylast from youtube_title_parse import get_artist_title from functions.lastfm_init import lastfm_network -def get_title(url): +def get_video_info(url): ytdl_opts = {'source_address': '0.0.0.0'} ydl = youtube_dl.YoutubeDL(ytdl_opts) with ydl: video = ydl.extract_info(url, download=False) title = video['title'] + description = video['description'] - return title + return (title, description) def get_artist_song(title): try: diff --git a/music.py b/music.py @@ -5,7 +5,7 @@ import re import configparser import functions.element as element from functions.extract_info import ( - get_title, + get_video_info, get_artist_song, get_artist_info, get_tags @@ -33,7 +33,7 @@ def youtube(event): message = message.split() url = message[0] - title = get_title(url) + title, desc = get_video_info(url) song_info = [title] artist, song = get_artist_song(title) @@ -45,6 +45,8 @@ def youtube(event): if tags and bio: song_info.append("Genre: " + tags) song_info.append(re.sub('<.*?>', '', bio)) + else: + song_info.append(desc) return song_info