Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions mps_youtube/commands/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from urllib.request import urlopen
from urllib.error import HTTPError, URLError
from .. import player
import os

try:
# pylint: disable=F0401
Expand Down Expand Up @@ -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. """
Expand Down
1 change: 1 addition & 0 deletions mps_youtube/helptext.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def helptext():
{2}r <number>{1} - show videos related to video <number>
{2}u <number>{1} - show videos uploaded by uploader of video <number>
{2}x <number>{1} - copy item <number> url to clipboard (requires pyperclip)
{2}m <number>{1} - feed item <number> url to mpv player (requires mpv)

{2}q{1}, {2}quit{1} - exit mpsyt
""".format(c.ul, c.w, c.y)),
Expand Down