diff --git a/mps_youtube/commands/misc.py b/mps_youtube/commands/misc.py index fb130a08..f1690f95 100644 --- a/mps_youtube/commands/misc.py +++ b/mps_youtube/commands/misc.py @@ -5,6 +5,7 @@ from urllib.request import urlopen from urllib.error import HTTPError, URLError from .. import player +import os try: # pylint: disable=F0401 @@ -181,6 +182,29 @@ def clipcopy_video(num): g.content = generate_songlist_display() +@command(r'm\s*(\d+)') +def open_in_mpv(num): + """ Feed video/playlist url to mpv. """ + if g.browse_mode == "ytpl": + + p = g.ytpls[int(num) - 1] + link = "https://youtube.com/playlist?list=%s" % p['link'] + + elif g.browse_mode == "normal": + item = (g.model[int(num) - 1]) + link = "https://youtube.com/watch?v=%s" % item.ytid + + else: + g.message = "mpv open not valid in this mode" + g.content = generate_songlist_display() + return + + os.system("mpv " + link) + g.message = "mpv opened. If not, make sure you have it installed" + g.content = generate_songlist_display() + + + @command(r'X\s*(\d+)', 'X') def clipcopy_stream(num): """ Copy content stream url to clipboard. """ diff --git a/mps_youtube/helptext.py b/mps_youtube/helptext.py index f0ae954e..b037638f 100644 --- a/mps_youtube/helptext.py +++ b/mps_youtube/helptext.py @@ -26,6 +26,7 @@ def helptext(): {2}r {1} - show videos related to video {2}u {1} - show videos uploaded by uploader of video {2}x {1} - copy item url to clipboard (requires pyperclip) + {2}m {1} - feed item url to mpv player (requires mpv) {2}q{1}, {2}quit{1} - exit mpsyt """.format(c.ul, c.w, c.y)),