mirror of
https://github.com/streamlink/streamlink
synced 2024-11-01 01:19:33 +01:00
5c3cf571ee
* Largely untested, introduces custom title attributes pulled from site APIs Included is support for {title}, {category}/{game}, and {author} for Twitch and Youtube Only tested (briefly) for Python 3 + Linux. Committing to test on other platforms (Windows) * bug-fix 1 * bug-fix 2 changing to list2cmdline turns out to not be necessary, since subprocess.call has already disabled the ability to break out by using `shell=False` also broke launching on windows. * bug-fix 3 move this to the pi3 area * allow user to escape $ with \$ in case the user wants to use format codes. comes at the expense of allowing streamers to insert format codes that only appear for streamlink users, but is not a security risk
55 lines
3.2 KiB
Python
55 lines
3.2 KiB
Python
# coding=utf8
|
|
import unittest
|
|
|
|
from streamlink.compat import is_win32, is_py3
|
|
from streamlink.utils import get_filesystem_encoding
|
|
from tests.test_cmdline import CommandLineTestCase
|
|
|
|
|
|
@unittest.skipIf(is_win32, "test only applicable in a POSIX OS")
|
|
class TestCommandLineWithTitlePOSIX(CommandLineTestCase):
|
|
def test_open_player_with_title_vlc(self):
|
|
self._test_args(["streamlink", "-p", "/usr/bin/vlc", "--title", "{title}", "http://test.se", "test"],
|
|
["/usr/bin/vlc", "--input-title-format", 'Test Title', "-"])
|
|
|
|
def test_open_player_with_unicode_author_vlc(self):
|
|
self._test_args(["streamlink", "-p", "/usr/bin/vlc", "--title", "{author}", "http://test.se", "test"],
|
|
["/usr/bin/vlc", "--input-title-format", u"Tѥst Āuƭhǿr", "-"])
|
|
|
|
def test_open_player_with_default_title_vlc(self):
|
|
self._test_args(["streamlink", "-p", "/usr/bin/vlc", "http://test.se", "test"],
|
|
["/usr/bin/vlc", "--input-title-format", 'http://test.se', "-"])
|
|
|
|
def test_open_player_with_default_title_vlc_args(self):
|
|
self._test_args(["streamlink", "-p", "\"/Applications/VLC/vlc\" --other-option", "http://test.se", "test"],
|
|
["/Applications/VLC/vlc", "--other-option", "--input-title-format", 'http://test.se', "-"])
|
|
|
|
def test_open_player_with_title_mpv(self):
|
|
self._test_args(["streamlink", "-p", "/usr/bin/mpv", "--title", "{title}", "http://test.se", "test"],
|
|
["/usr/bin/mpv", "--title", 'Test Title', "-"])
|
|
|
|
|
|
@unittest.skipIf(not is_win32, "test only applicable on Windows")
|
|
class TestCommandLineWithTitleWindows(CommandLineTestCase):
|
|
def test_open_player_with_title_vlc(self):
|
|
self._test_args(["streamlink", "-p", "c:\\Program Files\\VideoLAN\\vlc.exe", "--title", "{title}", "http://test.se", "test"],
|
|
"c:\\Program Files\\VideoLAN\\vlc.exe --input-title-format \"Test Title\" -")
|
|
|
|
@unittest.skipIf(is_py3, "Encoding is different in Python 2")
|
|
def test_open_player_with_unicode_author_vlc_py2(self):
|
|
self._test_args(["streamlink", "-p", "c:\\Program Files\\VideoLAN\\vlc.exe", "--title", "{author}", "http://test.se", "test"],
|
|
"c:\\Program Files\\VideoLAN\\vlc.exe --input-title-format \"" + u"Tѥst Āuƭhǿr".encode(get_filesystem_encoding()) + "\" -")
|
|
|
|
@unittest.skipIf(not is_py3, "Encoding is different in Python 2")
|
|
def test_open_player_with_unicode_author_vlc_py3(self):
|
|
self._test_args(["streamlink", "-p", "c:\\Program Files\\VideoLAN\\vlc.exe", "--title", "{author}", "http://test.se", "test"],
|
|
u"c:\\Program Files\\VideoLAN\\vlc.exe --input-title-format \"Tѥst Āuƭhǿr\" -")
|
|
|
|
def test_open_player_with_default_title_vlc(self):
|
|
self._test_args(["streamlink", "-p", "c:\\Program Files\\VideoLAN\\vlc.exe", "http://test.se", "test"],
|
|
"c:\\Program Files\\VideoLAN\\vlc.exe --input-title-format http://test.se -")
|
|
|
|
def test_open_player_with_default_arg_vlc(self):
|
|
self._test_args(["streamlink", "-p", "c:\\Program Files\\VideoLAN\\vlc.exe --argh", "http://test.se", "test"],
|
|
"c:\\Program Files\\VideoLAN\\vlc.exe --argh --input-title-format http://test.se -")
|