major_lee Posted May 19, 2021 Share Posted May 19, 2021 (edited) Problems with a bad connection. I try to watch videos online and they play a few seconds then stop. Over and over. Seeking through videos would also cause problems and the videos would have to start over, loading. Also reduces wasting bandwidth by watching the same video multiple times. Additionally save space by scaling the video and audio down. After some consideration I though about an elaborate way to resolve this problem, by landing a rover on mars and ....... ,yet then decided I can simply accomplish it with autoit. After some research while considering different approaches I found the best way to do it with RSS feeds.RSS feed downloading. The most practicable use is downloading while away. To watch videos later. A example of feeds file with RSS links feeds https://vimeo.com/adultswim/videos/rss https://vimeo.com/channels/bestoftheyear2016/videos/rss https://vimeo.com/channels/bestofthemonth/videos/rss https://vimeo.com/channels/bestofstaffpicks2017/videos/rss https://vimeo.com/newyorktimes/videos/rss https://vimeo.com/gopro/videos/rss https://vimeo.com/user703283/videos/rss in the folder it creates data.ini which associates the file with vlc title, there are some errors from the split. edit2 fix v1.16 logData($user[1], $user[2], $file) which later can be use for videoplaying main.au3 expandcollapse popup; major - Version 1.17 #include <InetConstants.au3> #include <File.au3> Opt("WinTitleMatchMode", 2) $sFilePath = @ScriptDir & "\feeds" Local $iCountLines = _FileCountLines($sFilePath) ConsoleWrite("$iCountLines" & ":" & $iCountLines & @CRLF) Local $hFileOpen = FileOpen($sFilePath, $FO_READ) Local $oXML = ObjCreate("Microsoft.XMLDOM") Local $titleInfo For $i = 1 To $iCountLines $sFileRead = FileReadLine($hFileOpen, $i) $url = $sFileRead If (@error) Then ConsoleWrite($i & ":" & "ExitLoop ... FileReadLine ERROR" & @CRLF) ExitLoop Else ConsoleWrite($i & ":" & $url & @CRLF) Local $sFile = @ScriptDir & "/rss.xml" Local $hDownload = InetGet($url, $sFile, $INET_FORCERELOAD) InetClose($hDownload) $oXML.load($sFile) $oParameters = $oXML.SelectNodes("/rss/channel/item") For $oParameter In $oParameters $oVideoId = $oParameter.SelectSingleNode("./link").text $split = StringSplit($oVideoId, '/') $file = $split[$split[0]] ConsoleWrite('+' & "link:" & $oVideoId & @CRLF) ConsoleWrite('+' & "file:" & $file & @CRLF) $fSaveDir = @ScriptDir & "\downlink\" If (FileExists($fSaveDir) == 0) Then DirCreate($fSaveDir) EndIf $fSave = $fSaveDir & $file & ".mp4" If (FileExists($fSave) == 0) Then ;https://wiki.videolan.org/Transcode ;https://wiki.videolan.org/Documentation:Modules/transcode/ ;https://wiki.videolan.org/Documentation:Streaming_HowTo/Command_Line_Examples/ ;;;;;; vb="1024" is bitrate adjust or remove for better quyality. 1024 is for lower bandwidth $pram = ' -vvv "' & $oVideoId & '" --qt-notification=0 --sout=#transcode{vcodec="h264",vb="1024",fps="25",vfilter=canvas{width=960,height=540},acodec="mp3",ab="12","channels=2",samplerate="32000"}:standard{access="file",dst=' & $fSave & '} vlc://quit"' ConsoleWrite('+' & 'C:\Progra~2\VideoLAN\VLC\vlc.exe' & $pram & @CRLF) Local $iPID = ShellExecute("vlc.exe", $pram, @ProgramFilesDir & "\VideoLAN\VLC\") Sleep(5000) $title = StringTrimRight(WinGetTitle("VLC"), 19) ConsoleWrite('>' & $iPID & ":" & $title & @CRLF) $user = StringSplit($title, '-') For $i = 2 To $user[0] ; Loop through the array returned by StringSplit to display the individual values. If ($i > 2) Then ;; needs tested to confirm replacing - $titleInfo = $titleInfo & "-" & $user[$i] Else $titleInfo = $titleInfo & $user[$i] EndIf Next ConsoleWrite('+' & $titleInfo & @CRLF) logData($user[1], $titleInfo, $file) ConsoleWrite('>' & $iPID & ":::ProcessWaitClose" & @CRLF) ProcessWaitClose($iPID) Else ConsoleWrite('!' & "Pass:::" & $fSave & @CRLF) EndIf Next ConsoleWrite($i & ":" & $sFileRead & @CRLF) EndIf Next Func logData($user, $title, $code) Local Const $sFilePath = $fSaveDir & "data.ini" ConsoleWrite($sFilePath & @CRLF) ConsoleWrite('+' & $user & ":" & $title & ":" & $code & @CRLF) IniWrite($sFilePath, $user, $code, $title) EndFunc ;==>logData Additionally, I haven't spent extensive time to testing it. It's functional for me after a few test. I am not sure if scaling video down through vlc effects download bandwidth. VLC could be downloading the HD version then scaling down through the pc. Might be something to look into. I will not endorse/support this use for other websites. Edit 2 - replaceCode ; Version 1.16 $title = WinGetTitle("VLC") ConsoleWrite('>' & $iPID & ":" & $title & @CRLF) $user = StringSplit($title, '-') logData($user[1], $user[2], $file) This remove most failures in title split. For data.ini video info Edit 3 - : fix split with for loop, add version identifier ; Version 1.17 $title = StringTrimRight (WinGetTitle("VLC"), 19 ) ConsoleWrite('>' & $iPID & ":" & $title & @CRLF) $user = StringSplit($title, '-') For $i = 2 To $user[0] ; Loop through the array returned by StringSplit to display the individual values. If ($i > 2) Then ;; needs tested to confirm replacing - $titleInfo = $titleInfo & "-" $user[$i] Else $titleInfo = $titleInfo & $user[$i] EndIf Next ConsoleWrite('+' & $titleInfo & @CRLF) logData($user[1], $titleInfo, $file) Edit 4 - Comments added vimeoDownload_descritpions.au3 The most simple version. If you don't want all the extra stuff and just want to learn from it with experimentation. Trimmed down to 16 lines vimeoDownload_basic.au3 Edit 5 - Line 43 added --qt-start-minimized to background the tasks. $pram = ' -vvv --qt-start-minimized "' & $oVideoId & '" --qt-notification=0 --sout=#transcode{vcodec="h264",vb="1024",fps="25",vfilter=canvas{width=960,height=540},acodec="mp3",ab="12","channels=2",samplerate="32000"}:standard{access="file",dst=' & $fSave & '} vlc://quit"' All Source files. majorangle/vimeoDownloader: Download vimeo videos from RSS feeds while away. (github.com) VLC is required Official download of VLC media player, the best Open Source player - VideoLAN If you have any questions I'll do my best to help. Edited September 7, 2023 by major_lee edit 5 FrancescoDiMuro 1 Link to comment Share on other sites More sharing options...
major_lee Posted May 22, 2021 Author Share Posted May 22, 2021 Useful addition vimeoDownloader/playlistGen.au3 at main · majorangle/vimeoDownloader (github.com) Functional with published version. Capable to generating playlist with many folders, for example each user having their own folder. expandcollapse popup#include <File.au3> $dir = @ScriptDir Local Const $sFilePath = $dir & '\playlist.m3u' Local $sString FileDelete($sFilePath) If Not FileWrite($sFilePath, "#EXTM3U" & @CRLF) Then ConsoleWrite("An error occurred whilst writing the temporary file.") EndIf ; Open the file for writing (append to the end of a file) and store the handle to a variable. Local $hFileOpen = FileOpen($sFilePath, $FO_APPEND) If $hFileOpen = -1 Then ConsoleWrite("An error occurred whilst writing the temporary file.") EndIf ; List all the files and folders in the desktop directory using the default parameters and return the full path. Local $aFileList = _FileListToArray($dir, Default, $FLTA_FOLDERS, True) If @error = 1 Then MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.") Exit EndIf If @error = 4 Then MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.") Exit EndIf For $vElement In $aFileList $sString = $sString & $vElement & @CRLF ConsoleWrite($vElement & @CRLF) ; Assign a Local variable the search handle of all files in the current directory. Local $hSearch = FileFindFirstFile($vElement & '\*.mp4') ; Check if the search was successful, if not display a message and return False. If $hSearch = -1 Then ConsoleWrite("Error: No files/directories matched the search pattern." & @CRLF) EndIf ; Assign a Local variable the empty string which will contain the files names found. Local $sFileName = "" While 1 $sFileName = FileFindNextFile($hSearch) ; If there is no more file matching the search. If @error Then ExitLoop ConsoleWrite($sFileName & @CRLF) ; Display the file name. $title = IniRead($vElement & '\data.ini', StringTrimRight($sFileName, 4), 'title', Null) FileWriteLine($hFileOpen, $vElement & '\' & $sFileName) WEnd ; Close the search handle. FileClose($hSearch) Next FileClose($hFileOpen) Link to comment Share on other sites More sharing options...
major_lee Posted May 22, 2021 Author Share Posted May 22, 2021 (edited) This is a more advanced playlist with titles. If i find time to get it functional and not an example then I will but I don't have to time to deal with it at the moment. Example video Adult Swim SMALLS Presents: S.T.A.R.H.A.W.K.S. on Vimeo Reference RSS https://vimeo.com/adultswim/videos/rss Each user has a folder with the data.ini Example(E:\downlink\adultswim\data.ini) File: E:\downlink\newyorktimes\508927445.mp4 Quote [508927445] author=adultswim title=S.T.A.R.H.A.W.K.S. date=2021-02-05 Additional user would be as such, E:\downlink\newyorktimes\data.ini ContainingAlmost Famous: The Lost Astronaut on Vimeo Quote [380740025] author=newyorktimes title=Almost Famous: The Lost Astronaut date=2019-12-20 While section is clearly the video id and the video id is the 380740025.mp4 Example location would be. E:\downlink\newyorktimes\380740025.mp4 expandcollapse popup#include <File.au3> $dir = 'E:\downlink\' Local Const $sFilePath = $dir & 'playlist.xspf' Local $sString FileDelete($sFilePath) If Not FileWrite($sFilePath, '<?xml version="1.0" encoding="UTF-8"?>' & @CRLF) Then ConsoleWrite("An error occurred whilst writing the temporary file.") EndIf ; Open the file for writing (append to the end of a file) and store the handle to a variable. Local $hFileOpen = FileOpen($sFilePath, $FO_APPEND) If $hFileOpen = -1 Then ConsoleWrite("An error occurred whilst writing the temporary file.") EndIf ; List all the files and folders in the desktop directory using the default parameters and return the full path. Local $aFileList = _FileListToArray($dir, Default, $FLTA_FOLDERS, True) If @error = 1 Then MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.") Exit EndIf If @error = 4 Then MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.") Exit EndIf FileWriteLine($hFileOpen, '<playlist>') FileWriteLine($hFileOpen, '<trackList>') FileWriteLine($hFileOpen, @CRLF) For $vElement In $aFileList $sString = $sString & $vElement & @CRLF ConsoleWrite($vElement & @CRLF) ; Assign a Local variable the search handle of all files in the current directory. Local $hSearch = FileFindFirstFile($vElement & '\*.mp4') ; Check if the search was successful, if not display a message and return False. If $hSearch = -1 Then ConsoleWrite("Error: No files/directories matched the search pattern." & @CRLF) Else ; Assign a Local variable the empty string which will contain the files names found. Local $sFileName = "" While 1 $sFileName = FileFindNextFile($hSearch) ; If there is no more file matching the search. If @error Then ExitLoop ConsoleWrite($sFileName & @CRLF) FileWriteLine($hFileOpen, '<track>') FileWriteLine($hFileOpen, '<location>'&$vElement & '\' & $sFileName&'</location>') $title = IniRead($vElement & '\data.ini', StringTrimRight($sFileName, 4), 'title', Null) FileWriteLine($hFileOpen, '<title>'& StringReplace($title,'&','')&'</title>') $author = IniRead($vElement & '\data.ini', StringTrimRight($sFileName, 4), 'author', Null) FileWriteLine($hFileOpen, '<creator>'&$author&'</creator>') FileWriteLine($hFileOpen, '</track>') FileWriteLine($hFileOpen, @CRLF) WEnd EndIf ; Close the search handle. FileClose($hSearch) Next FileWriteLine($hFileOpen, @CRLF) FileWriteLine($hFileOpen, '</trackList>') FileWriteLine($hFileOpen, '</playlist>') FileClose($hFileOpen) Edited May 24, 2021 by major_lee date format Link to comment Share on other sites More sharing options...
major_lee Posted May 24, 2021 Author Share Posted May 24, 2021 (edited) Playlist sorting example added. If i can find time/effort to make the examples functional with vimeo I will. Which mostly just has to do with formatting the data and RSS. extracting from internet such as , date, creator, title information. then assigning that correctly to the xml playlist. then it can be processed with this to sort by newest published. vimeoDownloader/playlistSort.au3 at main · majorangle/vimeoDownloader (github.com) expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <File.au3> #include <Array.au3> Local Const $sFilePath = 'E:\downlink\' & "playlist.xspf" Local Const $sFilePath_sort = 'E:\downlink\' & "playlist_sorted.xspf" Local $hFileOpen = FileOpen($sFilePath, $FO_READ) Local $oXML = ObjCreate("Microsoft.XMLDOM") Local $data[0][4], $sString $oXML.load($sFilePath) $oParameters = $oXML.SelectNodes("//playlist/trackList/track") For $oParameter In $oParameters Local $sFill = String($oParameter.SelectSingleNode("./date").text) & '|' & _ String($oParameter.SelectSingleNode("./location").text) & '|' & _ String($oParameter.SelectSingleNode("./creator").text) & '|' & _ String($oParameter.SelectSingleNode("./title").text) ConsoleWrite('!' & $sFill & @CRLF) _ArrayAdd($data, $sFill) Next _ArraySort($data, 1) _ArrayDisplay($data, "AFTER QuickSort descending") ;~ $data1 = _ArraySort($data, 0, 3, 6) FileDelete($sFilePath_sort) If Not FileWrite($sFilePath_sort, '<?xml version="1.0"?>' & @CRLF) Then ConsoleWrite("An error occurred whilst writing the temporary file.") EndIf ; Open the file for writing (append to the end of a file) and store the handle to a variable. Local $hFileOpen = FileOpen($sFilePath_sort, $FO_APPEND) If $hFileOpen = -1 Then ConsoleWrite("An error occurred whilst writing the temporary file.") EndIf If @error = 1 Then MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.") Exit EndIf If @error = 4 Then MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.") Exit EndIf FileWriteLine($hFileOpen, '<playlist>') FileWriteLine($hFileOpen, '<trackList>') FileWriteLine($hFileOpen, @CRLF) For $i = 0 To UBound($data, 1) - 1 FileWriteLine($hFileOpen, '<track>') FileWriteLine($hFileOpen, '<date>' & $data[$i][0] & '</date>') FileWriteLine($hFileOpen, '<location>' & $data[$i][1] & '</location>') FileWriteLine($hFileOpen, '<creator>' & $data[$i][2] & '</creator>') FileWriteLine($hFileOpen, '<title>' & $data[$i][3] & '</title>') FileWriteLine($hFileOpen, '</track>') FileWriteLine($hFileOpen, @CRLF) Next FileWriteLine($hFileOpen, @CRLF) FileWriteLine($hFileOpen, '</trackList>') FileWriteLine($hFileOpen, '</playlist>') FileClose($hFileOpen) Edited May 24, 2021 by major_lee Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now