- Dec 13, 2022
- 56
- 2,238
I made integrated scripts with resolution checks. You can paste any url (thumbnail.jpg; playlist.m3u8; video.m3u8) and it should "deal" with it. It is very convenient. The easiest one is by using thumbnail.jpg url. Just "Copy image address" for a thumbnail of the video you want.
Scripts with manual resolution selection:
Scripts with automatic highest resolution selection (RECOMMENDED):
Update 1 [Mar 28, 2024 11:33 PM UTC]:
Made video resolution selection easier. 1 for 1080p, 2 for 720p and 3 for 480p.
Update 2 [Mar 29, 2024 02:50 AM UTC]:
Apparently older (uploaded at Feb 08, 2024 or earlier) videos have different video.m3u8 urls. So I tried to fix my "universal" scripts. Removed ffmpeg download script with ffmpeg resolution "checker" for simplicity. You may replace corresponding lines (wget + type) with ffmpeg/ffprobe one if you need it. I am not sure if "480p/video.m3u8" urls exist.
Update 3 [Apr 29, 2024 01:23 AM UTC]:
I've made new batch scripts which automatically reads supported resolutions from playlist.m3u8 file and selects the highest supported one. It also does a simple check if you've entered a correct (thumbnail.jpg; playlist.m3u8; video.m3u8) url. Removes playlist.m3u8 file when it is not required. Asks for the file name at the start for a smoother download experience. I will add new automatic scripts later. Now I updated the old scripts to match the new automatic ones (except automatic resolution selection part).
Update 4 [Apr 29, 2024 01:48 AM UTC]:
Added scripts with automatic highest resolution selection.
Update 5 [Jan 10, 2025 04:06 PM UTC]:
Updated Chrome user agent "version" to the current one (v131 from v124). Technically this user agent "spoofing" is not required and you can remove all user agent options from the script code. But I think it is a good idea and probably safer to pretend to be a Chrome browser and not a wget/ffmpeg/VLC application.
NOTICES:
If you want to use your local ISP connection for downloads/streaming (videos/thumbnails don't load for you without VPN) and get a better speed, you must use split tunneling function of your VPN. E.g.: set it as allowed for your web browser. It somehow helps with access to playlist.m3u8/video.m3u8 files.
You can remove "-movflags faststart " from the scripts if you use SSD drive and want to reduce writes to it or just want that downloads would complete faster. This ffmpeg command moves a MOOV atom to the front of mp4 file so you get up to 3x writes physically. This option is useful if you will share videos online as they will start their playback slightly faster as a MOOV atom will be in the front of the file.
Scripts with manual resolution selection:
Code:
:start
@echo off
if exist "playlist.m3u8" del "playlist.m3u8"
set agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
set referer=https://iframe.mediadelivery.net/
:playlist
set /p turl="Enter url (thumbnail.jpg; playlist.m3u8; video.m3u8): " || set "turl="
if "%turl%" EQU "" goto playlist
echo.%turl% | findstr /R "\<https://.*/thumbnail\.jpg\>" && goto playlist-url || echo.%turl% | findstr /R "\<https://.*/playlist\.m3u8\>" && goto playlist-url || echo.%turl% | findstr /R "\<https://.*/video\.m3u8\>" && goto playlist-url || goto playlist
:playlist-url
set purl=%turl%
if "%purl%" EQU "" goto start
set "purl=%purl:thumbnail.jpg=playlist.m3u8%"
set "purl=%purl:1080p/video.m3u8=playlist.m3u8%"
set "purl=%purl:720p/video.m3u8=playlist.m3u8%"
set "purl=%purl:480p/video.m3u8=playlist.m3u8%"
set "purl=%purl:1920x1080/video.m3u8=playlist.m3u8%"
set "purl=%purl:1280x720/video.m3u8=playlist.m3u8%"
set "purl=%purl:842x480/video.m3u8=playlist.m3u8%"
echo Final playlist.m3u8 url: %purl%
echo.
echo Available resolutions:
if exist "playlist.m3u8" del "playlist.m3u8"
wget --user-agent="%agent%" --header="Referer: %referer%" -O playlist.m3u8 -q "%purl%"
type playlist.m3u8
set url=%turl%
:date
set /p older="Was video uploaded at 2024-02-08 or earlier (y/n)?: " || set "older="
if "%older%" EQU "" goto date
if "%older%" EQU "y" goto vres-old
if "%older%" EQU "n" goto vres
goto date
:vres
set /p res="Video resolution to stream, must be available (1080p[1]; 720p[2]; 480p[3]): " || set "res="
if "%res%" EQU "" goto vres
if "%res%" EQU "1080p" goto 1080p
if "%res%" EQU "1" goto 1080p
if "%res%" EQU "720p" goto 720p
if "%res%" EQU "2" goto 720p
if "%res%" EQU "480p" goto 480p
if "%res%" EQU "3" goto 480p
goto vres
:vres-old
set /p res="Video resolution to stream, must be available (1080p[1]; 720p[2]; 480p[3]): " || set "res="
if "%res%" EQU "" goto vres-old
if "%res%" EQU "1080p" goto 1080p-old
if "%res%" EQU "1" goto 1080p-old
if "%res%" EQU "720p" goto 720p-old
if "%res%" EQU "2" goto 720p-old
if "%res%" EQU "480p" goto 480p-old
if "%res%" EQU "3" goto 480p-old
goto vres-old
:stream
if exist "playlist.m3u8" del "playlist.m3u8"
echo Final video.m3u8 url: %url%
@echo on
"C:\Program Files\VideoLAN\VLC\vlc.exe" --http-user-agent="%agent%" --http-referrer="%referer%" "%url%"
@echo.
@goto start
:1080p
set "url=%url:thumbnail.jpg=1080p/video.m3u8%"
set "url=%url:playlist.m3u8=1080p/video.m3u8%"
set "url=%url:720p/video.m3u8=1080p/video.m3u8%"
set "url=%url:480p/video.m3u8=1080p/video.m3u8%"
goto stream
:720p
set "url=%url:thumbnail.jpg=720p/video.m3u8%"
set "url=%url:playlist.m3u8=720p/video.m3u8%"
set "url=%url:1080p/video.m3u8=720p/video.m3u8%"
set "url=%url:480p/video.m3u8=720p/video.m3u8%"
goto stream
:480p
set "url=%url:thumbnail.jpg=480p/video.m3u8%"
set "url=%url:playlist.m3u8=480p/video.m3u8%"
set "url=%url:1080p/video.m3u8=480p/video.m3u8%"
set "url=%url:720p/video.m3u8=480p/video.m3u8%"
goto stream
:1080p-old
set "url=%url:thumbnail.jpg=1920x1080/video.m3u8%"
set "url=%url:playlist.m3u8=1920x1080/video.m3u8%"
set "url=%url:1280x720/video.m3u8=1920x1080/video.m3u8%"
set "url=%url:842x480/video.m3u8=1920x1080/video.m3u8%"
goto stream
:720p-old
set "url=%url:thumbnail.jpg=1280x720/video.m3u8%"
set "url=%url:playlist.m3u8=1280x720/video.m3u8%"
set "url=%url:1920x1080/video.m3u8=1280x720/video.m3u8%"
set "url=%url:842x480/video.m3u8=1280x720/video.m3u8%"
goto stream
:480p-old
set "url=%url:thumbnail.jpg=842x480/video.m3u8%"
set "url=%url:playlist.m3u8=842x480/video.m3u8%"
set "url=%url:1920x1080/video.m3u8=842x480/video.m3u8%"
set "url=%url:1280x720/video.m3u8=842x480/video.m3u8%"
goto stream
Code:
:start
@echo off
if exist "playlist.m3u8" del "playlist.m3u8"
set agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
set referer=https://iframe.mediadelivery.net/
:fname
set /p name="Enter video file name (without .mp4): " || set "name="
if "%name%" EQU "" goto fname
:playlist
set /p turl="Enter url (thumbnail.jpg; playlist.m3u8; video.m3u8): " || set "turl="
if "%turl%" EQU "" goto playlist
echo.%turl% | findstr /R "\<https://.*/thumbnail\.jpg\>" && goto playlist-url || echo.%turl% | findstr /R "\<https://.*/playlist\.m3u8\>" && goto playlist-url || echo.%turl% | findstr /R "\<https://.*/video\.m3u8\>" && goto playlist-url || goto playlist
:playlist-url
set purl=%turl%
if "%purl%" EQU "" goto start
set "purl=%purl:thumbnail.jpg=playlist.m3u8%"
set "purl=%purl:1080p/video.m3u8=playlist.m3u8%"
set "purl=%purl:720p/video.m3u8=playlist.m3u8%"
set "purl=%purl:480p/video.m3u8=playlist.m3u8%"
set "purl=%purl:1920x1080/video.m3u8=playlist.m3u8%"
set "purl=%purl:1280x720/video.m3u8=playlist.m3u8%"
set "purl=%purl:842x480/video.m3u8=playlist.m3u8%"
echo Final playlist.m3u8 url: %purl%
echo.
echo Available resolutions:
if exist "playlist.m3u8" del "playlist.m3u8"
wget --user-agent="%agent%" --header="Referer: %referer%" -O playlist.m3u8 -q "%purl%"
type playlist.m3u8
set url=%turl%
:date
set /p older="Was video uploaded at 2024-02-08 or earlier (y/n)?: " || set "older="
if "%older%" EQU "" goto date
if "%older%" EQU "y" goto vres-old
if "%older%" EQU "n" goto vres
goto date
:vres
set /p res="Video resolution to download, must be available (1080p[1]; 720p[2]; 480p[3]): " || set "res="
if "%res%" EQU "" goto vres
if "%res%" EQU "1080p" goto 1080p
if "%res%" EQU "1" goto 1080p
if "%res%" EQU "720p" goto 720p
if "%res%" EQU "2" goto 720p
if "%res%" EQU "480p" goto 480p
if "%res%" EQU "3" goto 480p
goto vres
:vres-old
set /p res="Video resolution to download, must be available (1080p[1]; 720p[2]; 480p[3]): " || set "res="
if "%res%" EQU "" goto vres-old
if "%res%" EQU "1080p" goto 1080p-old
if "%res%" EQU "1" goto 1080p-old
if "%res%" EQU "720p" goto 720p-old
if "%res%" EQU "2" goto 720p-old
if "%res%" EQU "480p" goto 480p-old
if "%res%" EQU "3" goto 480p-old
goto vres-old
:download
if exist "playlist.m3u8" del "playlist.m3u8"
echo Final video.m3u8 url: %url%
@echo on
ffmpeg -hide_banner -user_agent "%agent%" -headers "Referer:%referer%" -i "%url%" -movflags faststart -fflags +bitexact -c copy "%name%.mp4"
@goto start
:1080p
set "url=%url:thumbnail.jpg=1080p/video.m3u8%"
set "url=%url:playlist.m3u8=1080p/video.m3u8%"
set "url=%url:720p/video.m3u8=1080p/video.m3u8%"
set "url=%url:480p/video.m3u8=1080p/video.m3u8%"
goto download
:720p
set "url=%url:thumbnail.jpg=720p/video.m3u8%"
set "url=%url:playlist.m3u8=720p/video.m3u8%"
set "url=%url:1080p/video.m3u8=720p/video.m3u8%"
set "url=%url:480p/video.m3u8=720p/video.m3u8%"
goto download
:480p
set "url=%url:thumbnail.jpg=480p/video.m3u8%"
set "url=%url:playlist.m3u8=480p/video.m3u8%"
set "url=%url:1080p/video.m3u8=480p/video.m3u8%"
set "url=%url:720p/video.m3u8=480p/video.m3u8%"
goto download
:1080p-old
set "url=%url:thumbnail.jpg=1920x1080/video.m3u8%"
set "url=%url:playlist.m3u8=1920x1080/video.m3u8%"
set "url=%url:1280x720/video.m3u8=1920x1080/video.m3u8%"
set "url=%url:842x480/video.m3u8=1920x1080/video.m3u8%"
goto download
:720p-old
set "url=%url:thumbnail.jpg=1280x720/video.m3u8%"
set "url=%url:playlist.m3u8=1280x720/video.m3u8%"
set "url=%url:1920x1080/video.m3u8=1280x720/video.m3u8%"
set "url=%url:842x480/video.m3u8=1280x720/video.m3u8%"
goto download
:480p-old
set "url=%url:thumbnail.jpg=842x480/video.m3u8%"
set "url=%url:playlist.m3u8=842x480/video.m3u8%"
set "url=%url:1920x1080/video.m3u8=842x480/video.m3u8%"
set "url=%url:1280x720/video.m3u8=842x480/video.m3u8%"
goto download
Scripts with automatic highest resolution selection (RECOMMENDED):
Code:
:start
@echo off
if exist "playlist.m3u8" del "playlist.m3u8"
set agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
set referer=https://iframe.mediadelivery.net/
:playlist
set /p turl="Enter url (thumbnail.jpg; playlist.m3u8; video.m3u8): " || set "turl="
if "%turl%" EQU "" goto playlist
echo.%turl% | findstr /R "\<https://.*/thumbnail\.jpg\>" && goto playlist-url || echo.%turl% | findstr /R "\<https://.*/playlist\.m3u8\>" && goto playlist-url || echo.%turl% | findstr /R "\<https://.*/video\.m3u8\>" && goto playlist-url || goto playlist
:playlist-url
set purl=%turl%
if "%purl%" EQU "" goto start
set "purl=%purl:thumbnail.jpg=playlist.m3u8%"
set "purl=%purl:1080p/video.m3u8=playlist.m3u8%"
set "purl=%purl:720p/video.m3u8=playlist.m3u8%"
set "purl=%purl:480p/video.m3u8=playlist.m3u8%"
set "purl=%purl:1920x1080/video.m3u8=playlist.m3u8%"
set "purl=%purl:1280x720/video.m3u8=playlist.m3u8%"
set "purl=%purl:842x480/video.m3u8=playlist.m3u8%"
echo Final playlist.m3u8 url: %purl%
echo.
echo Available resolutions:
if exist "playlist.m3u8" del "playlist.m3u8"
wget --user-agent="%agent%" --header="Referer: %referer%" -O playlist.m3u8 -q "%purl%"
type playlist.m3u8
set url=%turl%
:auto-check
echo.
findstr /c:"1080p/video.m3u8" playlist.m3u8 && goto 1080p || findstr /c:"720p/video.m3u8" playlist.m3u8 && goto 720p || findstr /c:"480p/video.m3u8" playlist.m3u8 && goto 480p || findstr /c:"1920x1080/video.m3u8" playlist.m3u8 && goto 1080p-old || findstr /c:"1280x720/video.m3u8" playlist.m3u8 && goto 720p-old || findstr /c:"842x480/video.m3u8" playlist.m3u8 && goto 480p-old || echo Supported resolutions were not found in playlist.m3u8 file. & echo. & goto start
echo.
:stream
if exist "playlist.m3u8" del "playlist.m3u8"
echo Final video.m3u8 url: %url%
@echo on
"C:\Program Files\VideoLAN\VLC\vlc.exe" --http-user-agent="%agent%" --http-referrer="%referer%" "%url%"
@echo.
@goto start
:1080p
set "url=%url:thumbnail.jpg=1080p/video.m3u8%"
set "url=%url:playlist.m3u8=1080p/video.m3u8%"
set "url=%url:720p/video.m3u8=1080p/video.m3u8%"
set "url=%url:480p/video.m3u8=1080p/video.m3u8%"
goto stream
:720p
set "url=%url:thumbnail.jpg=720p/video.m3u8%"
set "url=%url:playlist.m3u8=720p/video.m3u8%"
set "url=%url:1080p/video.m3u8=720p/video.m3u8%"
set "url=%url:480p/video.m3u8=720p/video.m3u8%"
goto stream
:480p
set "url=%url:thumbnail.jpg=480p/video.m3u8%"
set "url=%url:playlist.m3u8=480p/video.m3u8%"
set "url=%url:1080p/video.m3u8=480p/video.m3u8%"
set "url=%url:720p/video.m3u8=480p/video.m3u8%"
goto stream
:1080p-old
set "url=%url:thumbnail.jpg=1920x1080/video.m3u8%"
set "url=%url:playlist.m3u8=1920x1080/video.m3u8%"
set "url=%url:1280x720/video.m3u8=1920x1080/video.m3u8%"
set "url=%url:842x480/video.m3u8=1920x1080/video.m3u8%"
goto stream
:720p-old
set "url=%url:thumbnail.jpg=1280x720/video.m3u8%"
set "url=%url:playlist.m3u8=1280x720/video.m3u8%"
set "url=%url:1920x1080/video.m3u8=1280x720/video.m3u8%"
set "url=%url:842x480/video.m3u8=1280x720/video.m3u8%"
goto stream
:480p-old
set "url=%url:thumbnail.jpg=842x480/video.m3u8%"
set "url=%url:playlist.m3u8=842x480/video.m3u8%"
set "url=%url:1920x1080/video.m3u8=842x480/video.m3u8%"
set "url=%url:1280x720/video.m3u8=842x480/video.m3u8%"
goto stream
Code:
:start
@echo off
if exist "playlist.m3u8" del "playlist.m3u8"
set agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
set referer=https://iframe.mediadelivery.net/
:fname
set /p name="Enter video file name (without .mp4): " || set "name="
if "%name%" EQU "" goto fname
:playlist
set /p turl="Enter url (thumbnail.jpg; playlist.m3u8; video.m3u8): " || set "turl="
if "%turl%" EQU "" goto playlist
echo.%turl% | findstr /R "\<https://.*/thumbnail\.jpg\>" && goto playlist-url || echo.%turl% | findstr /R "\<https://.*/playlist\.m3u8\>" && goto playlist-url || echo.%turl% | findstr /R "\<https://.*/video\.m3u8\>" && goto playlist-url || goto playlist
:playlist-url
set purl=%turl%
if "%purl%" EQU "" goto start
set "purl=%purl:thumbnail.jpg=playlist.m3u8%"
set "purl=%purl:1080p/video.m3u8=playlist.m3u8%"
set "purl=%purl:720p/video.m3u8=playlist.m3u8%"
set "purl=%purl:480p/video.m3u8=playlist.m3u8%"
set "purl=%purl:1920x1080/video.m3u8=playlist.m3u8%"
set "purl=%purl:1280x720/video.m3u8=playlist.m3u8%"
set "purl=%purl:842x480/video.m3u8=playlist.m3u8%"
echo Final playlist.m3u8 url: %purl%
echo.
echo Available resolutions:
if exist "playlist.m3u8" del "playlist.m3u8"
wget --user-agent="%agent%" --header="Referer: %referer%" -O playlist.m3u8 -q "%purl%"
type playlist.m3u8
set url=%turl%
:auto-check
echo.
findstr /c:"1080p/video.m3u8" playlist.m3u8 && goto 1080p || findstr /c:"720p/video.m3u8" playlist.m3u8 && goto 720p || findstr /c:"480p/video.m3u8" playlist.m3u8 && goto 480p || findstr /c:"1920x1080/video.m3u8" playlist.m3u8 && goto 1080p-old || findstr /c:"1280x720/video.m3u8" playlist.m3u8 && goto 720p-old || findstr /c:"842x480/video.m3u8" playlist.m3u8 && goto 480p-old || echo Supported resolutions were not found in playlist.m3u8 file. & echo. & goto start
echo.
:download
if exist "playlist.m3u8" del "playlist.m3u8"
echo Final video.m3u8 url: %url%
@echo on
ffmpeg -hide_banner -user_agent "%agent%" -headers "Referer:%referer%" -i "%url%" -movflags faststart -fflags +bitexact -c copy "%name%.mp4"
@goto start
:1080p
set "url=%url:thumbnail.jpg=1080p/video.m3u8%"
set "url=%url:playlist.m3u8=1080p/video.m3u8%"
set "url=%url:720p/video.m3u8=1080p/video.m3u8%"
set "url=%url:480p/video.m3u8=1080p/video.m3u8%"
goto download
:720p
set "url=%url:thumbnail.jpg=720p/video.m3u8%"
set "url=%url:playlist.m3u8=720p/video.m3u8%"
set "url=%url:1080p/video.m3u8=720p/video.m3u8%"
set "url=%url:480p/video.m3u8=720p/video.m3u8%"
goto download
:480p
set "url=%url:thumbnail.jpg=480p/video.m3u8%"
set "url=%url:playlist.m3u8=480p/video.m3u8%"
set "url=%url:1080p/video.m3u8=480p/video.m3u8%"
set "url=%url:720p/video.m3u8=480p/video.m3u8%"
goto download
:1080p-old
set "url=%url:thumbnail.jpg=1920x1080/video.m3u8%"
set "url=%url:playlist.m3u8=1920x1080/video.m3u8%"
set "url=%url:1280x720/video.m3u8=1920x1080/video.m3u8%"
set "url=%url:842x480/video.m3u8=1920x1080/video.m3u8%"
goto download
:720p-old
set "url=%url:thumbnail.jpg=1280x720/video.m3u8%"
set "url=%url:playlist.m3u8=1280x720/video.m3u8%"
set "url=%url:1920x1080/video.m3u8=1280x720/video.m3u8%"
set "url=%url:842x480/video.m3u8=1280x720/video.m3u8%"
goto download
:480p-old
set "url=%url:thumbnail.jpg=842x480/video.m3u8%"
set "url=%url:playlist.m3u8=842x480/video.m3u8%"
set "url=%url:1920x1080/video.m3u8=842x480/video.m3u8%"
set "url=%url:1280x720/video.m3u8=842x480/video.m3u8%"
goto download
Update 1 [Mar 28, 2024 11:33 PM UTC]:
Made video resolution selection easier. 1 for 1080p, 2 for 720p and 3 for 480p.
Update 2 [Mar 29, 2024 02:50 AM UTC]:
Apparently older (uploaded at Feb 08, 2024 or earlier) videos have different video.m3u8 urls. So I tried to fix my "universal" scripts. Removed ffmpeg download script with ffmpeg resolution "checker" for simplicity. You may replace corresponding lines (wget + type) with ffmpeg/ffprobe one if you need it. I am not sure if "480p/video.m3u8" urls exist.
Update 3 [Apr 29, 2024 01:23 AM UTC]:
I've made new batch scripts which automatically reads supported resolutions from playlist.m3u8 file and selects the highest supported one. It also does a simple check if you've entered a correct (thumbnail.jpg; playlist.m3u8; video.m3u8) url. Removes playlist.m3u8 file when it is not required. Asks for the file name at the start for a smoother download experience. I will add new automatic scripts later. Now I updated the old scripts to match the new automatic ones (except automatic resolution selection part).
Update 4 [Apr 29, 2024 01:48 AM UTC]:
Added scripts with automatic highest resolution selection.
Update 5 [Jan 10, 2025 04:06 PM UTC]:
Updated Chrome user agent "version" to the current one (v131 from v124). Technically this user agent "spoofing" is not required and you can remove all user agent options from the script code. But I think it is a good idea and probably safer to pretend to be a Chrome browser and not a wget/ffmpeg/VLC application.
NOTICES:
If you want to use your local ISP connection for downloads/streaming (videos/thumbnails don't load for you without VPN) and get a better speed, you must use split tunneling function of your VPN. E.g.: set it as allowed for your web browser. It somehow helps with access to playlist.m3u8/video.m3u8 files.
You can remove "-movflags faststart " from the scripts if you use SSD drive and want to reduce writes to it or just want that downloads would complete faster. This ffmpeg command moves a MOOV atom to the front of mp4 file so you get up to 3x writes physically. This option is useful if you will share videos online as they will start their playback slightly faster as a MOOV atom will be in the front of the file.
Last edited:
Comment
If videos don't load in the browser for you, you must use a VPN. Servers in Japan should work.