製作腳本在VLC網路(MojaveOS)中自動載入m3u

製作腳本在VLC網路(MojaveOS)中自動載入m3u

所以我厭倦了總是必須打開 VLC / 開放網絡,複製並貼上我的 IPTV m3u 網路位址來加載。

有人可以幫助我(如果可能的話)創建一個腳本,該腳本將自動打開 VLC 並加載我的 m3u,而不必總是複製和貼上連結嗎?

我知道我可以用我的 m3u 創建一個簡單的播放列表,但問題是它們要么改變頻道和/或添加/刪除頻道。

因此,擁有一個可以加載並始終加載最新清單的自動腳本將會很有幫助。

答案1

桂道

vlc http://link.to/playlist.m3u

或純終端

nvlc http://link.to/playlist.m3u

答案2

如何打開 VLC 並加載我的 m3u,而不必總是複製和貼上連結?

使用命令列選項之一[stream]。如果您使用的是 Windows,您可以變更 VLC 捷徑以包含其他命令列選項。

Usage: vlc [options] [stream] ...
You can specify multiple streams on the commandline.
They will be enqueued in the playlist.
The first item specified will be played first.

Stream MRL syntax:

  [[access][/demux]://]URL[#[title][:chapter][-[title][:chapter]]]
  [:option=value ...]

  Many of the global --options can also be used as MRL specific :options.
  Multiple :option=value pairs can be specified.

URL syntax:
  file:///path/file              Plain media file
  http://host[:port]/file        HTTP URL
  ftp://host[:port]/file         FTP URL
  mms://host[:port]/file         MMS URL
  screen://                      Screen capture
  dvd://[device]                 DVD device
  vcd://[device]                 VCD device
  cdda://[device]                Audio CD device
  udp://[[<source address>]@[<bind address>][:<bind port>]]
                                 UDP stream sent by a streaming server
  vlc://pause:<seconds>          Pause the playlist for a certain time
  vlc://quit                     Special item to quit VLC

來源VLC 命令列幫助 - VideoLAN Wiki

如果您能夠使用 shell 腳本,那麼您可以使用以下腳本並根據您的特定要求進行修改:

if [[ "$1" == "" ]] ; then
    exit 1
fi

DUMMY=""

# location of playlist
PLAYLIST=/tmp/playlist.m3u

### the playlist is only updated from the Freebox if the playlist file does 
### not exist
###   simply remove the playlist file given by the location $PLAYLIST 
###   to force an update the next time the script is called
if [[ ! -f $PLAYLIST ]] ; then
    RAWPLAYLIST=`mktemp`
    echo "recovering Playlist"
    wget -q http://mafreebox.freebox.fr/freeboxtv/playlist.m3u -O $RAWPLAYLIST
### the following trick is found from:
### http://stackoverflow.com/questions/10207354/how-to-remove-all-of-the-diacritics-from-a-file
### and allows to replace accent characters by non-accent characters
    iconv -f utf8 -t ascii//TRANSLIT $RAWPLAYLIST > $PLAYLIST
    \rm $RAWPLAYLIST
fi

COMMAND="grep -v rtsp $PLAYLIST | grep -v EXTM3U "
for i in $@ ; do
    if [[ $i == "-dummy" ]] ; then
        DUMMY=dummy
    else
        COMMAND=$COMMAND" | grep -i "$i
    fi
done

COMMAND=$COMMAND" | head -1"

FLINE=`mktemp`
eval $COMMAND > $FLINE
LINE=`cat $FLINE`

N=`grep -xn -f $FLINE $PLAYLIST | cut -d : -f 1`

\rm $FLINE

N=$((N + 1))
LINK=`head -n $N $PLAYLIST | tail -1`

if [[ "$LINE" == "" ]] ; then
    echo "No matching channel found"
    exit 1
fi

echo "Opening vlc for: $LINE"
echo $LINK

if [[ "$DUMMY" == "" ]] ; then
    vlc "$LINK" --network-caching=1500 --no-loop
fi

您將其保存在 PATH 中的某個位置(可能在您的私人 bin 資料夾中: ~/bin/如果它位於您的 PATH 中),例如FB_VIEW.sh,您可以透過 使其可執行chmod +x FB_VIEW.sh

那麼簡單的使用就是:

FB_VIEW.sh "list of patterns"

啟動播放清單中包含這些模式的第一個頻道(由空格分隔的子模式之間的順序並不重要)。模式列表可能包含單字“-dummy”,在這種情況下,僅顯示找到的頻道和 rtsp 鏈接,但實際上並未啟動 vlc。模式匹配不區分大小寫。您也可以使用頻道的節目編號作為模式,但在 Freebox 上,相同編號可能會有不同的流量(Adsl、TNT、HD、標準、bas-debit),而且您可能需要新增第二個模式,例如 HD 或TNT 選擇合適的電視通量。

在這個版本中,第一次啟動腳本時,它將從 Freebox 下載播放清單(使用 wget),用非重音字元替換重音字元並將其儲存在預設位置 /tmp/playlist.m3u (我發現了竅門昨天為此)。當您稍後想要強制更新播放清單時,只需刪除現有文件,更新將在下次呼叫腳本時完成(這大約需要 1-2 秒)。請注意,免費會定期對播放清單套用某些(通常是適度的)變更。

您可以輕鬆修改播放清單的名稱/預設位置,也可以刪除「更新部分」(如果您不喜歡它),在這種情況下,您必須在適當的位置手動提供播放清單。

來源播放 m3u 播放清單中的特定項目! - VideoLAN 論壇


進一步閱讀

相關內容