Skip to content

Instantly share code, notes, and snippets.

@pastparty
Created March 6, 2024 12:21
Show Gist options
  • Select an option

  • Save pastparty/7594b706db54251d61db70c569962f85 to your computer and use it in GitHub Desktop.

Select an option

Save pastparty/7594b706db54251d61db70c569962f85 to your computer and use it in GitHub Desktop.
Basic vidyaviewa
@echo off
setlocal enabledelayedexpansion
:: Set the directory to the location of the batch file.
set "dir=%~dp0"
:: Create or overwrite the HTML file.
echo ^<html^> > "%dir%index.html"
echo ^<head^> >> "%dir%index.html"
echo ^<style^> >> "%dir%index.html"
echo .modal {display: none; position: fixed; z-index: 1; padding-top: 100px; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgb(0,0,0); background-color: rgba(0,0,0,0.4);} >> "%dir%index.html"
echo .modal-content {background-color: #fefefe; margin: auto; padding: 20px; border: 1px solid #888; width: 80%;} >> "%dir%index.html"
echo ^</style^> >> "%dir%index.html"
echo ^</head^> >> "%dir%index.html"
echo ^<body^> >> "%dir%index.html"
:: Use a for loop to go through the files in the directory and its subdirectories.
for /R "%dir%" %%F in (*.mp4 *.avi *.mkv *.mov) do (
:: Check if there is a poster.jpg in the same directory as the current file.
if exist "%%~dpFposter.jpg" (
:: If there is a poster, create a link in the HTML file with the poster image.
echo ^<a href="#" onclick="document.getElementById('modal').style.display='block';document.getElementById('modal-content').src='%%F';"^>^<img src="%%~dpFposter.jpg" alt="Poster"^> %%~nxF^</a^>^<br^> >> "%dir%index.html"
) else (
:: If there is no poster, create a link in the HTML file without the poster image.
echo ^<a href="#" onclick="document.getElementById('modal').style.display='block';document.getElementById('modal-content').src='%%F';"^>%%~nxF^</a^>^<br^> >> "%dir%index.html"
)
)
:: Add the modal window to the HTML file.
echo ^<div id="modal" class="modal"^> >> "%dir%index.html"
echo ^<div class="modal-content"^> >> "%dir%index.html"
echo ^<video id="modal-content" style="width:100%" controls^> >> "%dir%index.html"
echo ^<source src="" type="video/mp4"^> >> "%dir%index.html"
echo Your browser does not support the video tag. >> "%dir%index.html"
echo ^</video^> >> "%dir%index.html"
echo ^</div^> >> "%dir%index.html"
echo ^</div^> >> "%dir%index.html"
:: Add the JavaScript to close the modal window.
echo ^<script^> >> "%dir%index.html"
echo var modal = document.getElementById('modal'); >> "%dir%index.html"
echo window.onclick = function(event) {if (event.target == modal) {modal.style.display = "none";}} >> "%dir%index.html"
echo ^</script^> >> "%dir%index.html"
:: Close the HTML tags.
echo ^</body^> >> "%dir%index.html"
echo ^</html^> >> "%dir%index.html"
endlocal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment