UsingExpectWithVlc ```plaintext $ telnet myhost 2048 Trying 192.168.0.50... Connected to myhost. Escape character is '^]'. VLC media player 3.0.18 Vetinari Password: Welcome, Master > volume 26 ``` Help is obtained in the obvious way ```plaintext > help ... see below ``` The [script](/aw/os/shell/ScriptCommand) is useful for getting transcripts from things like telnet sessions. (This saves from the need for each and every application to implement its own transcription facilities.) ## Helper scripts ### Auto login `tvlc` logs you in with a know password (low security since this is a home network and it's just [VLC](VlcPlayer)). I allocate telnet ports in the range 5000--5999 and often have multiple instances, each with its own playlist, so that instead of clearing/loading new playlists, I simply alt-tab between them. ```expect #!/usr/bin/expect set timeout 1 set host "[lindex $argv 0]" set tport "[lindex $argv 1]" puts "tport '$tport'" if { $tport == "" } { set tport 0 } set port "[expr 3000 + $tport]" set password "boingboing" spawn gtelnet $host $port expect { timeout { puts "timeout" ; exit 1 } "Password:" } send "$password\r" expect { timeout { puts "timeout welcome" ; exit 1 } "Welcome, Master" } interact ``` ### Command Sender I'm not an expert in Python's `subprocess` module, so I don't know how to capture the output. Anyway, use it like ```bash tvlcmd hostname 15 next ``` to advance the VLC player to the next item in the playlist. The script: ```python from subprocess import run, Popen, PIPE a = r"""set timeout 5 set host "[lindex $argv 0]" set tport "[lindex $argv 1]" puts "tport '$tport'" if { $tport == "" } { set tport 0 } set port "[expr 4000 + $tport]" set password "random_flumpy_thing" spawn gtelnet $host $port expect { timeout { puts "timeout pw" ; exit 1 } "Password:" } send "$password\r" expect { timeout { puts "timeout welcome" ; exit 1 } "Welcome, Master" } sleep 0.1 """ import sys args = sys.argv[1:] try: host, port, *args = args if len(args) == 0: raise ValueError() except ValueError: print(f"{sys.argv[0]} [...]") exit(1) b="sleep 1" args = [arg.replace('"','\"').replace(r"[",r"\[").replace(r"]",r"\]") for arg in args] args = [f"send \"{arg}\\r\"" for arg in args] scr="\n".join([a]+args+[b]) proc = Popen(["expect","-f","-",host,port],stdin=PIPE,stdout=PIPE) m = proc.communicate(input=scr.encode()) ``` ### Cygwin To add a file via `tvlcmd` on cygwin (say `localhost` and port 7001), use ``` tvlcmd localhost 1 "add file:///$(cygpath -w "$(readlink -f "video.mp4")" | tr '\\\\' '/')" ``` ## VLC Telnet help This is the output of the `help` command with my current version of [VLC](VlcPlayer) (3.0.18). ```plaintext +----[ VLM commands ] |help | Commands Syntax: | new (name) vod|broadcast|schedule [properties] | setup (name) (properties) | show [(name)|media|schedule] | del (name)|all|media|schedule | control (name) [instance_name] (command) | save (config_file) | export | load (config_file) | Media Proprieties Syntax: | input (input_name) | inputdel (input_name)|all | inputdeln input_number | output (output_name) | option (option_name)[=value] | enabled|disabled | loop|unloop (broadcast only) | mux (mux_name) | Schedule Proprieties Syntax: | enabled|disabled | append (command_until_rest_of_the_line) | date (year)/(month)/(day)-(hour):(minutes):(seconds)|now | period (years_aka_12_months)/(months_aka_30_days)/(days)-(hours):(minutes):(seconds) | repeat (number_of_repetitions) | Control Commands Syntax: | play [input_number] | pause | stop | seek [+-](percentage) | [+-](seconds)s | [+-](milliseconds)ms +----[ CLI commands ] | add XYZ . . . . . . . . . . . . . . . . . . . . add XYZ to playlist | enqueue XYZ . . . . . . . . . . . . . . . . . queue XYZ to playlist | playlist . . . . . . . . . . . . . show items currently in playlist | search [string] . . search for items in playlist (or reset search) | delete [X] . . . . . . . . . . . . . . . . delete item X in playlist | move [X][Y] . . . . . . . . . . . . move item X in playlist after Y | sort key . . . . . . . . . . . . . . . . . . . . . sort the playlist | sd [sd] . . . . . . . . . . . . . show services discovery or toggle | play . . . . . . . . . . . . . . . . . . . . . . . . . . play stream | stop . . . . . . . . . . . . . . . . . . . . . . . . . . stop stream | next . . . . . . . . . . . . . . . . . . . . . . next playlist item | prev . . . . . . . . . . . . . . . . . . . . previous playlist item | goto, gotoitem . . . . . . . . . . . . . . . . . goto item at index | repeat [on|off] . . . . . . . . . . . . . . toggle playlist repeat | loop [on|off] . . . . . . . . . . . . . . . . toggle playlist loop | random [on|off] . . . . . . . . . . . . . . toggle playlist random | clear . . . . . . . . . . . . . . . . . . . . . clear the playlist | status . . . . . . . . . . . . . . . . . . . current playlist status | title [X] . . . . . . . . . . . . . . set/get title in current item | title_n . . . . . . . . . . . . . . . . next title in current item | title_p . . . . . . . . . . . . . . previous title in current item | chapter [X] . . . . . . . . . . . . set/get chapter in current item | chapter_n . . . . . . . . . . . . . . next chapter in current item | chapter_p . . . . . . . . . . . . previous chapter in current item | | seek X . . . . . . . . . . . seek in seconds, for instance `seek 12' | pause . . . . . . . . . . . . . . . . . . . . . . . . toggle pause | fastforward . . . . . . . . . . . . . . . . . . set to maximum rate | rewind . . . . . . . . . . . . . . . . . . . . . set to minimum rate | faster . . . . . . . . . . . . . . . . . . faster playing of stream | slower . . . . . . . . . . . . . . . . . . slower playing of stream | normal . . . . . . . . . . . . . . . . . . normal playing of stream | rate [playback rate] . . . . . . . . . . set playback rate to value | frame . . . . . . . . . . . . . . . . . . . . . play frame by frame | fullscreen, f, F [on|off] . . . . . . . . . . . . toggle fullscreen | info [X] . . information about the current stream (or specified id) | stats . . . . . . . . . . . . . . . . show statistical information | get_time . . . . . . . . . seconds elapsed since stream's beginning | is_playing . . . . . . . . . . . . 1 if a stream plays, 0 otherwise | get_title . . . . . . . . . . . . . the title of the current stream | get_length . . . . . . . . . . . . the length of the current stream | | volume [X] . . . . . . . . . . . . . . . . . . set/get audio volume | volup [X] . . . . . . . . . . . . . . . raise audio volume X steps | voldown [X] . . . . . . . . . . . . . . lower audio volume X steps | achan [X] . . . . . . . . . . . . set/get stereo audio output mode | atrack [X] . . . . . . . . . . . . . . . . . . . set/get audio track | vtrack [X] . . . . . . . . . . . . . . . . . . . set/get video track | vratio [X] . . . . . . . . . . . . . . . set/get video aspect ratio | vcrop, crop [X] . . . . . . . . . . . . . . . . set/get video crop | vzoom, zoom [X] . . . . . . . . . . . . . . . . set/get video zoom | vdeinterlace [X] . . . . . . . . . . . . . set/get video deinterlace | vdeinterlace_mode [X] . . . . . . . set/get video deinterlace mode | snapshot . . . . . . . . . . . . . . . . . . . . take video snapshot | strack [X] . . . . . . . . . . . . . . . . . set/get subtitle track | | vlm . . . . . . . . . . . . . . . . . . . . . . . . . load the VLM | description . . . . . . . . . . . . . . . . . describe this module | help, ? [pattern] . . . . . . . . . . . . . . . . . a help message | longhelp [pattern] . . . . . . . . . . . . . . a longer help message | lock . . . . . . . . . . . . . . . . . . . . lock the telnet prompt | logout . . . . . . . . . . . . . . exit (if in a socket connection) | quit . . . . . . . . quit VLC (or logout if in a socket connection) | shutdown . . . . . . . . . . . . . . . . . . . . . . . shutdown VLC +----[ end of help ] ```