Skin packaging script and extraction script

About usage, announcement and development of skins for VLC
drewkeller
Blank Cone
Blank Cone
Posts: 25
Joined: 17 Sep 2013 14:59

Skin packaging script and extraction script

Postby drewkeller » 04 Jan 2014 09:46

After doing the same commands over and over, packaging and testing a skin gets very tedious. Here's a script that makes it less so (for Windows).

The vlt file is actually in zip format here instead of the (usual?) .tar.gz.
VLC doesn't seem to like the flavor of tar/gzip I've been able to generate from various Windows programs, but it's ok with zip (not 7z though).

Code: Select all

@echo off echo =============================================================================== echo :: This script provides a way to package files into a VLC skin file (.vlt) echo :: You'll need 7zip in your path or add it explicitly using the path variable echo :: in the script (below). echo :: echo :: To use... echo :: Drag'n'drop the folder containing your skin files onto this script. echo :: A .vlt file will be created as a sibling to the folder. echo :: If you create a file named "_package_testVideo.txt" whose contents is echo :: the full path and filename of a media file, VLC will start with the skin echo :: applied and playing that file. echo =============================================================================== echo. echo. :: If you don't have 7zip or VLC in your path, uncomment and edit as needed below set path=%path%;G:\Utility\File\7zip;G:\Media\Players\vlc :: Read the path to the test video set /p testVideo= <%~n0_testVideo.txt set skinFolder=%1 set skinName=%~n1 :: in case it was in a folder unpacked by the Skin Editor set skinName=%skinName:_unpacked=% set folder=%~dp1 set log="%~n0_log.txt" if (%~1) == () call :Error "You need to drop a folder on this script or send it as an argument." 1 :: variable checks echo. echo. skinName : %skinName% echo. folder : %folder% echo. testVideo : %testVideo% echo. vltFile : %folder%%skinName%.vlt echo. log : %log% echo. :: Check existence of dependencies 7za >NUL call :CheckError "7zip was not found" :: not a good way to do this for VLC :: vlc --play-and-exit --version >NUL :: call :CheckError "VLC was not found" set zipFile="%folder%%skinName%.zip" set tarFile="%folder%%skinName%.tar" set gzFile="%folder%%skinName%.tar.gz" set vltFile="%folder%%skinName%.vlt" set bakFile="%folder%%skinName%.vlt.bak" ::if not exist "%skinFolder%\skin.dtd" ( :: call :Error "The skin.dtd file is not in the skin folder." ::) goto :CreateZip :: VLC doesn't work with the files created by this method for some reason. :CreateGzip :: Update files to the tar archive (intermediate) echo. &echo === Creating .tar file... 7za a %tarFile% "%skinFolder%\*" -ttar call :CheckError "An error occurred while creating the tar file." :: Update the tar.gz file (the format vlc uses) echo. &echo === Creating .tar.gz file... ::tar -c -f %tarFile% "%skinFolder%\" ::gzip -c %tarFile% > %gzFile% 7za a %gzFile% %tarFile% -tgzip call :CheckError "An error occurred while creating the gzip file." echo. :: Transition the tar.gz file to .vlt call :CreateBackup %gzFile% .tar.gz goto :CheckVLC :CreateZip echo. &echo === Creating .zip file... call :CheckError "An error occurred while creating the zip file." 7za a %zipFile% "%skinFolder%\*" -tzip call :CreateBackup %zipFile% .zip goto :CheckVLC :CreateBackup :: %1 is the full filename of the archive (.tar.gz or .zip) :: %2 is the extension of the archive for messages if not exist %1 (call :Error "The %2 file is missing.") if exist %vltFile% ( if exist %bakFile% ( echo. &echo === Deleting old backup file... del %bakFile% call :CheckError "The .bak file could not be deleted." ) echo. &echo === Backing up previous vlt file... rename %vltFile% "%skinName%.vlt.bak" call :CheckError "The .bak file could not be created." ) echo. &echo === Renaming %2 -^> .vlt ... rename %1 "%skinName%.vlt" call :CheckError "The %2 file could not be renamed to .vlt" goto :eof :: We want to test the new skin in VLC, right? :CheckVLC color 0A if exist "%testVideo%" ( echo. &echo === Starting VLC to test skin ... >%log% echo vlc "%testVideo%" >>%log% echo --extraintf=http:logger --verbose=1 --file-logging --logfile=%log% >>%log% echo -I skins2 --skins2-last="%folder%%skinName%.vlt" >>%log% echo. vlc "%testVideo%" ^ --extraintf=http:logger --verbose=1 --file-logging --logfile=%log% ^ -I skins2 --skins2-last="%folder%%skinName%.vlt" if not %errorlevel% == 0 ( type vlc-log.txt ) call :CheckError "Failed to load VLC." ) timeout /T 3 goto:eof :CheckError ::echo. errorlevel : '%errorlevel%' if not %errorlevel% == 0 ( call :Error %1 ) goto:eof :Error :: The first argument is the message :: If a second argument is provided, the "additional details" message is supporessed. color 0C set msg=%1 :: strip quotes from ends, if any for /f "useback tokens=*" %%a in ('%msg%') do set msg=%%~a echo. echo ================================================================================ echo. ERROR: %msg% if "%2"=="" ( echo. Check the execution area above for additional details. ) echo. pause >NUL exit 1 :ReplaceUnpacked set skinName=%skinName:_unpacked=% goto:eof
Here's an extraction script. Drag'n'drop your .vlt file onto the script and it will extract to a folder of the same name. It will try to extract using .tar.gz format first and then fall back to auto-detection if that fails. Note that I had the latest alpha version of 7zip (7z.exe) and that it gave errors when piping the tar.gz commands where the stable 9.20 version works fine (7za.exe). I have both files in the same 7zip folder now. I suppose I could do it as two steps without the pipe and then delete the intermediate file... meh...

Code: Select all

@echo off echo =============================================================================== echo :: This script provides a way to extract files to a folder. echo :: You'll need 7zip in your path or add it explicitly. echo :: Note: The 7-Zip 9.32 alpha exits with error code 2 for .tar.gz compressed echo :: files. echo :: 7-Zip 9.20 (2010-11-18) works ok (uses 7za.exe as below). echo :: To use... echo :: Drag'n'drop the skin file (.vlt) onto this script. echo :: A folder with the same base name will be created as a sibling to the echo :: skin file. echo =============================================================================== echo. echo. :: If you don't have 7zip or VLC in your path, uncomment and edit as needed below set path=%path%;G:\Utility\File\7zip;G:\Media\Players\vlc set skinFile="%1" set skinName=%~n1 set skinFolder="%~dp1%skinName%" set folder="%~dp0" if (%~1) == () call :Error "You need to drop a file on this script or send it as an argument." 1 :: variable checks echo. echo. skinName : %skinName% echo. skinFile : %skinFile% echo. skinFolder : %skinFolder% echo. folder : %folder% echo. :: Check existence of dependencies 7za >NUL call :CheckError "7zip was not found" :TryExtractGzip echo. &echo === Attempting to extract as .tar.gz ... echo 7za x %skinFile% -so ^| 7za x -aoa -si -ttar -o%skinFolder% echo. &echo ================================================================================ 7za x %skinFile% -so | 7za x -aoa -si -ttar -o%skinFolder% echo ================================================================================ if %errorlevel% == 0 ( goto:DoneSuccess ) echo errorlevel : %errorlevel% :TryExtractAutoDetect echo. &echo === Attempting to extract using auto-detection ... set cmd=7za x %skinFile% -aoa -o%skinFolder% echo %cmd% echo. &echo ================================================================================ %cmd% echo ================================================================================ call :CheckError "An error occurred while extracting the skin file." :: We want to test the new skin in VLC, right? :DoneSuccess color 0A pause timeout /T 3 goto:eof :CheckError ::echo. errorlevel : '%errorlevel%' if not %errorlevel% == 0 ( call :Error %1 ) goto:eof :Error :: The first argument is the message :: If a second argument is provided, the "additional details" message is supporessed. color 0C set msg=%1 :: strip quotes from ends, if any for /f "useback tokens=*" %%a in ('%msg%') do set msg=%%~a echo. echo ================================================================================ echo. ERROR: %msg% if "%2"=="" ( echo. Check the execution area above for additional details. ) echo. pause >NUL exit 1
Updates 2013-01-05:
* Updated packaging script:
** rename to _package.bat so it's at the top of the file list when sorted by name
** the error subroutine performs exit with error code 1 instead of goto:eof
** Add logging to file of the VLC session to aid troubleshooting skin errors
** Add check for whether an folder was dropped (argument was provided)
* Added extraction script
Last edited by drewkeller on 05 Jan 2014 08:58, edited 2 times in total.

erwan10
Developer
Developer
Posts: 415
Joined: 02 Nov 2008 23:16

Re: Skin packaging script

Postby erwan10 » 04 Jan 2014 15:52

thanks a lot on behalf of all Windows skins2 developpers !

Both zip and .tar.gz formats are equally okay. The former may be more prevalent with MS Windows, whereas the latter is more prevalent with Linux. But, both work fine on both platforms. Yet, if you plan on supporting both platforms, make sure to keep consistent in naming your files. Linux is always case-sensitive, whereas Windows is a lot less demanding in this matter.

drewkeller
Blank Cone
Blank Cone
Posts: 25
Joined: 17 Sep 2013 14:59

Re: Skin packaging script

Postby drewkeller » 04 Jan 2014 22:06

Hmm... so VLC would handle filenames in zip files differently from gzip? I went through and made sure all the files were lowercase in both the filesystem and the theme.xml file, so they ought to be consistent now (this skin was originally written by someone else).

Here's what I've tried...
* gzip created by 7zip: doesn't work
* gzip created by gzip and tar binaries from their project pages[1]: doesn't work
* zip created by 7zip: works
* gzip created by Skin Editor: works

[1] http://savannah.gnu.org/projects/tar and http://www.gzip.org/

A binary comparison of the 7zip generated gzip and the Skin Editor generated gzip shows that they are substantially different, not just a header or something. I went through the files listed in 7zip for both of those, and the original filesizes and compressed filesizes matched for all. I looked at a few other programs that support gzip, but most actually use 7zip as their engine. I don't know the internals of the various compression formats enough to figure out what's really going on any farther than this.

One thing of interest to note: The Skin Editor has an item under File > Export as VLT... which creates a VLT file. However, "export" is a bit of a misnomer because it PACKAGES rather than EXPORTS (i.e. the files in the vlt match the files on the disk as-is instead of writing out the internal interpretation from the Skin Editor). So, for the final packaging of the skin for distribution, it might be desired to use this packaging function to create a gzip file from the skin editor.

drewkeller
Blank Cone
Blank Cone
Posts: 25
Joined: 17 Sep 2013 14:59

Re: Skin packaging script and extraction script

Postby drewkeller » 05 Jan 2014 07:19

Added extraction script (in first post)

I tried gzip using the stable version of 7zip, just to give it a whirl, but VLC still didn't like the result.


Return to “Skins”

Who is online

Users browsing this forum: No registered users and 11 guests