Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 1360

Help: Rainmeter Skins • Re: Windows-Terminal / File Download / YT-Download

$
0
0
Ok, I think it's ready for testing, let me know if there's any issue or question.

ytdlpTest_1.5.rmskin
Note: The skin requires yt-dlp and ffmpeg to work, which are not included. Instructions for download and install are included in the INI file though.


I pretty much changed everything on the lua script, and converted it into a "state machine".

On the script measure side pretty much everything remains the same but, and it's important to note, I have added a new variable called ytFixedArguments which is important to NOT MODIFY, as it contains the logs necessary for the script to track the download states as well as the files path, name and number. Those arguments must be included on any implementation.

I've introduced new states, and these are all of them:
  • Waiting...
  • Starting...
  • Downloading...
  • Post-processing...
  • Finished...
  • Stopping...
  • Download Complete!
  • Download Stopped!
  • Error!
I have also introduced 3 new functions:
  • [&ScriptMeasure:GetFilePath()]
  • [&ScriptMeasure:GetFileName()]
  • [&ScriptMeasure:GetFileNumber()]
Those functions will return the last downloaded video Path, Name and Number.
Important note: Since the log file is in ANSI format, videos with special characters on their title will not return a correct title. I couldn't find a way to make the log file UTF, so if anyone has any idea on how to do that, please share :D

You can download more than one video at a time by simply specifying more than one URL, or simply downloading a full playlist, those functions will return the info about the last one completed.
The download will be considered complete once all videos have been downloaded and post-processed.

Errors should be more explicit now, the script measure will show Error! as its string value and the actual error will be in the log.

I tested many formats and options but obviously is difficult to test the whole range of options yt-dlp has, hopefully there are no new issues.


Here's the timer plugin version:

Code:

[Rainmeter]Update=-1DynamicWindowSize=1AccurateText=1;Stop if downloading before unloading skin.OnCloseAction=[!CommandMeasure ytProgress "Stop()"];This skin allows you to use yt-dlp.exe to download youtube videos.;IMPORTANT NOTES:;(1) This skin requires yt-dlp.exe to work, please download it from here: https://github.com/yt-dlp/yt-dlp?tab=readme-ov-file#release-files;Download yt-dlp.exe (second option) and place it insisde @Resources\yt-dlp folder.;(2) While not completely necessary to run the yt-dlp.exe, ffmpeg is required for merging separate video and audio files,;as well as for various post-processing tasks. Download it from here: https://github.com/yt-dlp/FFmpeg-Builds?tab=readme-ov-file#ffmpeg-static-auto-builds;Click on the blue WINDOWS X64 banner to download it, then install it following this quick tutorial: https://www.youtube.com/watch?v=K7znsMo_48I&ab_channel=BigStupidTech;Finally restart your pc and you're good to go.[Variables]; yt-dlp variables: All these variables are required to implement this script.;Video or Videos URLs to Download:;Single video test:ytVideoURL=https://www.youtube.com/watch?v=cUzklzVXJwo;Multiple videos test:;ytVideoURL=https://www.youtube.com/watch?v=mNf-KArtRiA https://www.youtube.com/watch?v=ZAqIoDhornk;Playlist test:;ytVideoURL=https://www.youtube.com/playlist?list=PLZPZq0r_RZOPNy28FDBys3GVP2LiaIyP_;Path to the lua file:ytLuaPath=#@#yt-dlp\ytdlp.lua;Path to yt-dlp.exe:ytDlpPath=#@#yt-dlp\yt-dlp.exe;Path to log file:ytLogPath=#@#yt-dlp\ytdlp_log.log;Path to Downloads folderytDownloadsPath=#@#yt-dlp\Downloads\;yt-dlp.exe USER arguments:These are your arguments, play with settings here.ytUserArguments=--merge-output-format mp4 --remux-video mp4 -S vcodec:h264,lang,quality,res,fps,hdr:12,acodec:aac --embed-thumbnail --add-metadata -o "#ytDownloadsPath#%(title)s-[%(resolution)s].%(ext)s";yt-dlp.exe FIXED arguments: These arguments are required and should not be modified.ytFixedArguments=--progress --newline --print before_dl:[DOWNLOADING] --print post_process:[POSTPROCESSING] --print after_move:[FINISHED_%(video_autonumber)s]%(filepath)s;---;Other variablesbarWidth=300barHeight=30;--- Measures ---;[ytProgress];Script MeasureMeasure=ScriptScriptFile=#ytLuaPath#;Set the log file path: This path is not relative to the skin folder, so make sure you use built-in variables like #@# for @Resources or #ROOTCONFIGPATH# for the skin's folder.LogPath=#ytLogPath#;Set the Stop and Start Measure Names: This measures are necessary to start, stop the yt-dlp.exe process from the script.StartMeasureName=ytStartStopMeasureName=ytStop;These are for the bar progress meter:MinValue=0MaxValue=100;We update all meters and measures from here when this measure updates:OnUpdateAction=[!UpdateMeasureGroup ytdlp][!UpdateMeterGroup ytdlp][!Redraw]DynamicVariables=1;We define the bar colors depending on the states.IfMatch = ^Download Stopped!$IfMatchAction= [!SetOption Bar BarColor "187,112,038"]IfMatch2=^Starting...|Downloading...|Post‑processing...|Finished...$IfMatchAction2=[!SetOption Bar BarColor "184,184,184"]IfMatch3= ^Download Complete!$IfMatchAction3=[!SetOption Bar BarColor "050,187,038"]IfMatch4= ^Waiting...$IfMatchAction4=[!SetOption Bar BarColor "0,0,0,1"]IfMatch5= ^Error!$IfMatchAction5=[!SetOption Bar SolidColor "187,038,038"][!SetOption Bar BarColor "038,187,187"]IfNotMatchAction5=[!SetOption Bar SolidColor "40,40,40,255"][ytStart];Starts yt-dlp.exe with given arguments. Only modify "ytUserArguments".Measure=PluginPlugin=RunCommandParameter=>"#ytLogPath#" "#ytDlpPath#" #ytFixedArguments# #ytUserArguments# #ytVideoURL#State=HideOutputType=ANSIFinishAction=[!UpdateMeasure #CURRENTSECTION#][!UpdateMeasure ytProgress][!CommandMeasure Timer "Stop"][ytStop];Stops yt-dlp.exe: This measure is executed when you command the script to stop. It kills yt-dlp.exe process.Measure=PluginPlugin=RunCommandParameter=taskkill /F /IM yt-dlp.exeState=HideOutputType=ANSIFinishAction=[!UpdateMeasure #CURRENTSECTION#][!UpdateMeasure ytProgress][ytFilePath];Returns downloaded video full path when the download is finished.Measure=StringGroup=ytdlpString=[&ytProgress:GetFilePath()]DynamicVariables=1UpdateDivider=-1[ytFileName];Returns downloaded video file name when the download is finished.Measure=StringGroup=ytdlpString=[&ytProgress:GetFileName()]DynamicVariables=1UpdateDivider=-1[ytFileNumber];Returns downloaded video file number when the download is finished.Measure=CalcGroup=ytdlpFormula=[&ytProgress:GetFileNumber()]DynamicVariables=1UpdateDivider=-1[Timer];Makes ytProgress measure update faster and reports the elapsed time.Measure=PluginPlugin=TimerUpdateTimer=1000Interval=250ResetOnStop=-1OnUpdateAction=[!UpdateMeter StateText][!Redraw]OnTickAction=[!UpdateMeasure ytProgress];--- Meter Styles ---;[Text];Meter StyleAntiAlias=1FontFace=RobotoFontSize=14FontColor=255,255,255,255SolidColor=0,0,0,1StringEffect=BorderFontEffectColor=0,0,0,255StringAlign=LeftCenterPadding=4,2,4,2Y=r;--- Meters ---;[Bar];-- Progress Bar Meter --; The bar that shows the download progress.Meter=BarGroup=ytdlpMeasureName=ytProgressW=#barWidth#H=#barHeight#BarColor=0,255,0,255SolidColor=40,40,40,255BarOrientation=HorizontalClipString=1UpdateDivider=-1MiddleMouseUpAction=[!CommandMeasure ytProgress Reset()][!CommandMeasure Timer "Reset"] ToolTipTitle=Hint:ToolTipText=MMB - ResetToolTipIcon=Info[StateText];-- Download State Meter --; The text that displays the download state.Meter=StringGroup=ytdlpMeasureName=ytProgressMeasureName2=TimerMeterStyle=TextInLinePattern=\d+:\d+:\d+InLineSetting=Size | 9FontSize=8Text=%1#CRLF#%2Y=(#barHeight#/2)rx=rUpdateDivider=-1[PercentText];-- Download Percentage Meter --; The text that displays the download percentage value.Meter=StringGroup=ytdlpMeterStyle=TextStringAlign=RightCenterDynamicVariables=1Text=[ytProgress:1]%X=#barWidth#UpdateDivider=-1[FileNameText];-- File Name Meter --; The text that displays the downloaded file name.Meter=StringGroup=ytdlpMeterStyle=TextStringAlign=CenterCenterMeasureName=ytFileNameFontSize=8Padding=0,0,0,0W=#barWidth#h=#barheight#SolidColor=40,40,40,255UpdateDivider=-1X=(#barWidth#/2)Y=3RLeftMouseUpAction=["[#ytDownloadsPath]"] MiddleMouseUpAction=["[&ytFilePath]"] ToolTipTitle=Hint:ToolTipText=LMB - Open Downloads Folder #CRLF#MMB - Play Downloaded VideoToolTipIcon=Info[ButtonStart];--Start Button Meter --;Meter=StringMeterStyle=TextStringAlign=CenterCenterX=(#barWidth#/2-40)Y=10RSolidColor=40,40,40,255Text=StartLeftMouseUpAction=[!CommandMeasure ytProgress Start()][!CommandMeasure Timer "Start"][ButtonStop];--Stop Button Meter --;Meter=StringMeterStyle=TextStringAlign=CenterCenterX=25RY=rSolidColor=40,40,40,255Text=StopLeftMouseUpAction=[!CommandMeasure ytProgress Stop()][!CommandMeasure Timer "Stop"]

Statistics: Posted by RicardoTM — Today, 3:36 am



Viewing all articles
Browse latest Browse all 1360

Latest Images

Trending Articles



Latest Images