def _create_arguments(self): if self.namedpipe: filename = self.namedpipe.path elif self.filename: filename = self.filename elif self.http: filename = self.http.url else: filename = "-" args = self.args.format(filename=filename) cmd = self.cmd extra_args = [] if self.title is not None: # vlc if self.player_name == "vlc": # see https://wiki.videolan.org/Documentation:Format_String/, allow escaping with \$ self.title = self.title.replace("$", "$$").replace(r'\$$', "$") extra_args.extend(["--input-title-format", self.title]) # mpv if self.player_name == "mpv": # see https://mpv.io/manual/stable/#property-expansion, allow escaping with \$, respect mpv's $> self.title = self._mpv_title_escape(self.title) extra_args.extend(["--title", self.title]) # player command if is_win32: eargs = maybe_decode(subprocess.list2cmdline(extra_args)) # do not insert and extra " " when there are no extra_args return maybe_encode(u' '.join([cmd] + ([eargs] if eargs else []) + [args]), encoding=get_filesystem_encoding()) return shlex.split(cmd) + extra_args + shlex.split(args)
def create_title(plugin=None): if args.title and plugin: formatter = get_formatter(plugin) title = formatter.title(maybe_decode(args.title, get_filesystem_encoding()), defaults=DEFAULT_STREAM_METADATA) else: title = args.url return title
def _create_arguments(self): if self.namedpipe: filename = self.namedpipe.path if is_win32: if self.player_name == "vlc": filename = "stream://\\{0}".format(filename) elif self.player_name == "mpv": filename = "file://{0}".format(filename) elif self.filename: filename = self.filename elif self.http: filename = self.http.url else: filename = "-" extra_args = [] if self.title is not None: # vlc if self.player_name == "vlc": # see https://wiki.videolan.org/Documentation:Format_String/, allow escaping with \$ self.title = self.title.replace("$", "$$").replace(r'\$$', "$") extra_args.extend([u"--input-title-format", self.title]) # mpv if self.player_name == "mpv": # see https://mpv.io/manual/stable/#property-expansion, allow escaping with \$, respect mpv's $> self.title = self._mpv_title_escape(self.title) extra_args.append(u"--force-media-title={}".format(self.title)) # potplayer if self.player_name == "potplayer": if filename != "-": # PotPlayer - About - Command Line # You can specify titles for URLs by separating them with a backslash (\) at the end of URLs. # eg. "http://...\title of this url" self.title = self.title.replace('"', '') filename = filename[:-1] + '\\' + self.title + filename[-1] if is_py2: filename = filename.encode("utf-8") args = self.args.format( **{ PLAYER_ARGS_INPUT_DEFAULT: filename, PLAYER_ARGS_INPUT_FALLBACK: filename }) cmd = self.cmd # player command if is_win32: eargs = maybe_decode(subprocess.list2cmdline(extra_args)) # do not insert and extra " " when there are no extra_args return ' '.join([cmd] + ([eargs] if eargs else []) + [args]) return shlex.split(cmd) + extra_args + shlex.split(args)
def create_title(plugin=None): if args.title and plugin: title = LazyFormatter.format( maybe_decode(args.title, get_filesystem_encoding()), title=lambda: plugin.get_title() or DEFAULT_STREAM_METADATA["title"], author=lambda: plugin.get_author() or DEFAULT_STREAM_METADATA["author"], category=lambda: plugin.get_category() or DEFAULT_STREAM_METADATA["category"], game=lambda: plugin.get_category() or DEFAULT_STREAM_METADATA["game"], url=plugin.url ) else: title = args.url return title
def _create_arguments(self): if self.namedpipe: filename = self.namedpipe.path elif self.filename: filename = self.filename elif self.http: filename = self.http.url else: filename = "-" extra_args = [] if self.title is not None: # vlc if self.player_name == "vlc": # see https://wiki.videolan.org/Documentation:Format_String/, allow escaping with \$ self.title = self.title.replace("$", "$$").replace(r'\$$', "$") extra_args.extend(["--input-title-format", self.title]) # mpv if self.player_name == "mpv": # see https://mpv.io/manual/stable/#property-expansion, allow escaping with \$, respect mpv's $> self.title = self._mpv_title_escape(self.title) extra_args.extend(["--title", self.title]) # potplayer if self.player_name == "potplayer": if filename != "-": # PotPlayer - About - Command Line # You can specify titles for URLs by separating them with a backslash (\) at the end of URLs. ("http://...\title of this url") self.title = self.title.replace('"', '') filename = filename[:-1] + '\\' + self.title + filename[-1] args = self.args.format(filename=filename) cmd = self.cmd # player command if is_win32: eargs = maybe_decode(subprocess.list2cmdline(extra_args)) # do not insert and extra " " when there are no extra_args return maybe_encode(u' '.join([cmd] + ([eargs] if eargs else []) + [args]), encoding=get_filesystem_encoding()) return shlex.split(cmd) + extra_args + shlex.split(args)
def test_log_unicode(self): log, output = self._new_logger() logger.root.setLevel("info") log.info(u"Special Character: Ѩ") self.assertEqual(maybe_decode(output.getvalue()), u"[test][info] Special Character: Ѩ\n")
def test_maybe_decode_py3(self): self.assertEqual(maybe_decode(u"test \u07f7"), u"test \u07f7")
def test_maybe_decode_py2(self): self.assertEqual(maybe_decode("test \xdf\xb7"), u"test \u07f7")