aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/watch.py
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2018-08-06 19:25:14 -0700
committerJames Taylor <user234683@users.noreply.github.com>2018-08-06 19:25:14 -0700
commitb02b5b87b3bae22a9c2667c5b1652ddd7e5afbcb (patch)
tree320b87f9dfb9f3911e9b726e860e11b6dad40ff5 /youtube/watch.py
parent09837e9fa6a7c905699dc0f62fcbe466ca9a21c5 (diff)
downloadyt-local-b02b5b87b3bae22a9c2667c5b1652ddd7e5afbcb.tar.lz
yt-local-b02b5b87b3bae22a9c2667c5b1652ddd7e5afbcb.tar.xz
yt-local-b02b5b87b3bae22a9c2667c5b1652ddd7e5afbcb.zip
list music used in video if available
Diffstat (limited to 'youtube/watch.py')
-rw-r--r--youtube/watch.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/youtube/watch.py b/youtube/watch.py
index c669f5e..cfe827b 100644
--- a/youtube/watch.py
+++ b/youtube/watch.py
@@ -296,6 +296,10 @@ def extract_info(downloader, *args, **kwargs):
except YoutubeError as e:
return str(e)
+music_list_table_row = Template('''<tr>
+ <td>$attribute</td>
+ <td>$value</td>
+''')
def get_watch_page(query_string):
id = urllib.parse.parse_qs(query_string)['v'][0]
downloader = YoutubeDL(params={'youtube_include_dash_manifest':False})
@@ -343,7 +347,32 @@ def get_watch_page(query_string):
else:
related_videos_html = ''
+ music_list = info['music_list']
+ if len(music_list) == 0:
+ music_list_html = ''
+ else:
+ music_list_html = '''<hr>
+<table>
+ <caption>Music</caption>
+ <tr>
+ <th>Artist</th>
+ <th>Title</th>
+ <th>Album</th>
+ </tr>
+'''
+ for track in music_list:
+ music_list_html += '''<tr>\n'''
+ for attribute in ('artist', 'title', 'album'):
+ try:
+ value = track[attribute]
+ except KeyError:
+ music_list_html += '''<td></td>'''
+ else:
+ music_list_html += '''<td>''' + html.escape(value) + '''</td>'''
+ music_list_html += '''</tr>\n'''
+ music_list_html += '''</table>\n'''
+
download_options = ''
for format in info['formats']:
@@ -371,5 +400,6 @@ def get_watch_page(query_string):
related = related_videos_html,
comments = comments_html,
more_comments_button = more_comments_button,
+ music_list = music_list_html,
)
return page \ No newline at end of file