Page 1 of 1

tv

Posted: 13 Dec 2019 20:18
by tea
Any testers out there for my iptv channel grabber program? Or how to fix it up. First batch program.

you need VLC


:start
cls
@ECHO ******** FIND MY STREAM ********
@ECHO OFF >NUL
@echo off
::SETLOCAL DisableDelayedExpansion
:FOR /F "usebackq delims=" %%a in (`"findstr /n ^^ C:\Users\laptop\Desktop\us.txt"`) do (
:: set "var=%%a"
:: SETLOCAL EnableDelayedExpansion
:: set "var=!var:*:=!"
:: echo(!var!
:: ENDLOCAL
::)
ECHO Type in a TV channel.

ECHO -------------------------------------------------------
ECHO ENTER CHANNEL TO SEARCH
set "input1="
set /p"input1="

SETLOCAL EnableExtensions EnableDelayedExpansion
set "chromepath=c:\Program Files (x86)\Google\Chrome\Application" path to chrome
set "site=http://visearch.net/iptv/web"
set "site2=https://iptvextreme.eu/"
set "engine=?q"
start "" !site!/!engine!=!input1!"
setlocal enableExtensions enableDelayedExpansion
:: uri encoded input of form: http://name.com:8080/<username>/<password>/30356
:pass
set "input="
ECHO ---------------------------

ECHO Outputs that have .m3u8 extenstions will be rejected.
ECHO If this happens select a new channel from web page then paste.

ECHO Paste from Website channel URL
set /p "input="
if not "x%input:u8=%" == "x%input%" goto :pass
:main
echo Options;
echo 1 : View channel on VLC
echo 2 : Full account channel list -download list-
echo 3 : Check account status
echo 4 : Add to playlist
echo 5 : If stream fails .Paste new channel
echo 6 : If you want a new channel select this option to Enter Another channel
:: Prompt for input,
set /p "strMenu=Enter desired number:"

:: Compare input through if commands,
:: `if not defined strMenu goto :menu` can be used here if prefered.
echo %strMenu%
if "%strMenu%" equ "1" goto vlc
if "%strMenu%" equ "2" goto CL
if "%strMenu%" equ "3" goto CS
if "%strMenu%" equ "4" goto ML
if "%strMenu%" equ "5" goto pass
if "%strMenu%" equ "6" goto start
pause
::Set "LogFile=C:\Users\laptop\Desktop\test.txt"
:vlc
start "" "C:\Program Files\VideoLAN\VLC\vlc.exe" !input! :sout=#display :sout-all :sout-keep
goto main
:CL
:: variables of form
:: "%%~a" = "http:"
:: "%%~b" = "name.com:8080"
:: "%%~c" = "<username>"
:: "%%~d" = "<password>"
:: "%%~e" = "30356"
:: output of form http://name.com:8080/get.php?username=< ... .&type=m3u
set "output="
for /f "tokens=1-5 delims=/" %%a in ("!input!") do (
set "output=%%~a//%%~b/get.php?username=%%~c&password=%%~d&type=m3u"
)
start "" !output!
goto main
:ML
echo #EXTINF:-1, %input1%>> TV.M3U
echo %input%>> TV.M3U

goto main
:CS
Echo Web page opens go to bottom of page and paste in last field.
pause
@echo off
et "output="
for /f "tokens=1-5 delims=/" %%a in ("!input!") do (
set "output=%%~a//%%~b/get.php?username=%%~c&password=%%~d&type=m3u"
)

echo(!output!
@(
cmd /E:ON /V:ON /cecho(!output!
)|clip
@echo off

start "" !site2!

cls
goto main
echo off
goto :eof

Re: tv

Posted: 19 Dec 2019 01:47
by Hackoo
I have tested it and it worked like a charm for me :wink: :D
Thank you for this nice share bro :wink:

Re: tv

Posted: 21 Dec 2019 04:37
by Hackoo
Hi :wink:
Can you please try my draft version and tell me if this script will work or not on your side ?
All your comments are welcomed to improve it :lol:
Thank you !

Code: Select all

@echo off & color 0A & Mode 95,3
Title Stream IPTV Grabber by Hackoo 2019
echo(
echo      Type your favorite Channel Name for trying to catch and extract its link :
Set /p "Channel_Name="
Set "OutPut_All_Streams=%~dp0%Channel_Name%_All_Streams.txt"
Set "OutPut_Filter_Streams=%~dp0%Channel_Name%_Filter_Streams.txt"
Cls 
echo(
echo     Please wait a while ... trying to get all links about your favorite channel "%Channel_Name%"
REM Just to show links into console
::Call :GRAB_IPTV_STREAM_LINK "%Channel_Name%" CON
Call :GRAB_IPTV_STREAM_LINK "%Channel_Name%" "%OutPut_All_Streams%"
REM To get rid from all links that cointains m3u8 and firstonetv strings
Type "%OutPut_All_Streams%" | find /I /V "m3u8" | find /I /V "firstonetv">"%OutPut_Filter_Streams%"
::If Exist "%OutPut_All_Streams%" Start "" "%OutPut_All_Streams%" 
::If Exist "%OutPut_Filter_Streams%" Start "" "%OutPut_Filter_Streams%" & Exit
Call :M3U_PlayList_Creator %Channel_Name% %OutPut_Filter_Streams% 
Exit
::--------------------------------------------------------------------------------------
:GRAB_IPTV_STREAM_LINK <Channel_Name> <OutPutFile>
Set "VBSFILE=%Temp%\GrabIPTV.vbs"
(
	echo SourceCode = GetSourceCode("http://visearch.net/iptv/web?q="^& %1^)
	echo Stream_Link = Extract(SourceCode^)
	echo wscript.echo Stream_Link
	echo '------------------------------------------------
	echo Function Extract(Channel_Name^)
	echo 	Dim regEx, Match, Matches
	echo 	Set regEx = New RegExp
	echo 	regEx.Pattern = "(data-url=\x22)(http.*)(\x22)"
	echo 	regEx.IgnoreCase = True
	echo 	regEx.Global = True
	echo 	Set Matches = regEx.Execute(Channel_Name^)
	echo 	For each Match in Matches
	echo 		Stream_Link = Stream_Link ^& Match.SubMatches(1^) ^& vbCrlf
	echo 	Next
	echo 	Extract = Stream_Link
	echo End Function
	echo '------------------------------------------------
	echo Function GetSourceCode(Channel_Name^)
	echo Dim http
	echo Set http = CreateObject("Microsoft.XMLHTTP"^)
	echo http.open "GET",Channel_Name,False
	echo On Error Resume Next
	echo http.send
	echo	If Err.Number = 0 Then
	echo		If http.Status = "200" Then
	echo			GetSourceCode = http.ResponseText
	echo		Else
	echo 			GetSourceCode = "HTTP " ^& http.Status ^& " " ^& _
	echo 			http.StatusText
	echo		End If
	echo	Else
	echo		GetSourceCode = "Error " ^& Err.Number ^& " " ^& Err.Source ^& " " ^& _
	echo		Err.Description
	echo	End If
	echo	On Error GoTo 0
	echo End Function
	echo '------------------------------------------------
)>"%VBSFILE%"
Cscript //NoLogo "%VBSFILE%" > "%~2"
If Exist "%VBSFILE%" Del "%VBSFILE%"
Exit /b
::--------------------------------------------------------------------------------------
:M3U_PlayList_Creator <Channel_Name> <InputFile> 
echo #EXTM3U>"%~n2.m3u"
set /a "N=0"
SetLocal EnableDelayedExpansion
@for /f "delims=" %%a in ('Type %2') do (
	Set /a N+=1
	(
		echo #EXTINF:-1,!N!-%1
		echo %%a
	)>>"%~n2.m3u"
)
If Exist "%~n2.m3u" Start "" "%~n2.m3u"
Exit /b 
::--------------------------------------------------------------------------------------

Re: tv

Posted: 24 Dec 2019 00:54
by tea
That looks good, if I have some time I can see what I can do.

Re: tv

Posted: 24 Dec 2019 01:02
by tea
I've found some dead links from searches how can we remove them from the final output? How hard would it be to disallow mp4 as well?
You did an awesome job Hackoo!

Re: tv

Posted: 31 Mar 2021 17:54
by krypton
Sorry to bump an old thread, but I've used this batch script for a while and the site this goes off of has updated and ever since the batch script only gives blank notepad results. Is there any plans to update this script or a way that I can edit something on mine? Thanks!

Re: tv

Posted: 02 Apr 2021 14:12
by Hackoo
krypton wrote:
31 Mar 2021 17:54
Sorry to bump an old thread, but I've used this batch script for a while and the site this goes off of has updated and ever since the batch script only gives blank notepad results. Is there any plans to update this script or a way that I can edit something on mine? Thanks!
Thank you for the notification bro :wink:
Yep the site is updated with a new version, so we can not deal directly with the source code !
We must search what JSON response we can got !
I think is not a good idea to deal with batch or vbscript if we want to parse a JSON Response !
So, hope that someone give us an idea with Powershell to get what we want as result ! :roll:

Re: tv

Posted: 03 Apr 2021 02:29
by penpen

Re: tv

Posted: 05 Apr 2021 10:57
by Hackoo
Hi :wink:
I found a nice and a good resource to get a large IPTV links from this Github IPTV
So, i created a Powershell script to get a list of all available channels in JSON format and parsing it to get and build our m3u file :P :wink:

Github-IPTV-Parser.ps1

Code: Select all

cls
#Powershell Script Created by Hackoo on 05/04/2021 to get and parse an IPTV JSON file and to build from it a M3U file
$url="https://iptv-org.github.io/iptv/channels.json"
$JSON_File = $psscriptroot +"\iptv-channels.json"
$M3U_File  = $psscriptroot +"\iptv-channels.m3u" 
$start_time = Get-Date

Try {
	$http_request = New-Object -ComObject Msxml2.ServerXMLHTTP
	$http_request.open('GET', $url, $false)
	$http_request.send()
	Write-Host "Sever Web Response : "$http_request.status - $http_request.statusText -ForegroundColor Green -BackgroundColor Black
	}
Catch
	{
		Write-Host "Message: $($_.Exception.Message)" -ForegroundColor Red -BackgroundColor Black
		Exit
	}

$BS = New-Object -ComObject ADODB.Stream
$BS.type = 1
$BS.open()
$BS.Write($http_request.ResponseBody)
$BS.SaveToFile($JSON_File,2)

$jsonContent = GC $JSON_File | ConvertFrom-Json
$Channel_Count = $jsonContent.Name.count
##################################### Building M3U File ###########################################
Write-Host "Please wait a While ... Builiding M3U File is in Progress ..." -ForegroundColor Green -BackgroundColor Black
"#EXTM3U" | Out-File -FilePath $M3UFile
for ($i=0; $i -lt $Channel_Count; $i++) {
    '#EXTINF:-1,'+ $jsonContent.name[$i] | Out-File -FilePath $M3UFile -Append
	$jsonContent.url[$i] | Out-File -FilePath $M3UFile -Append
}
##################################### Building M3U File ###########################################
$Elapsed_Time = "$((Get-Date).Subtract($start_time).Minutes) Minutes(M) : $((Get-Date).Subtract($start_time).Seconds) Secondes(s)"
Write-Output "Running Script Time taken is : $Elapsed_Time"
If ((Test-Path -path $M3U_File) -eq 1) {Start $M3U_File}
EDIT :

Code: Select all

######################################################################################################################
#Powershell Script Created by Hackoo on 11/04/2021 to get and parse an IPTV JSON file and to build from it a M3U file
######################################################################################################################
cls
$CopyRight= [char]0x00A9 + " Hackoo 2021"
Function Show-NotifyBalloon($BalloonTipIcon,$Title,$Message)
{
	[system.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms') | Out-Null
	$Windir = $env:WINDIR #[System.Environment]::ExpandEnvironmentVariables("%WINDIR%")
	$Global:Balloon = New-Object System.Windows.Forms.NotifyIcon
	#$Balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon((Get-Process -id $pid | Select-Object -ExpandProperty Path))
	$Balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($Windir+"\System32\nslookup.exe")
	$Balloon.BalloonTipIcon = $BalloonTipIcon
	$Balloon.BalloonTipText = $Message
	$Balloon.BalloonTipTitle = $Title
	$Balloon.Visible = $true
	$Balloon.ShowBalloonTip(2000)
	Start-Sleep -Seconds 10
	$Balloon.Visible =$false; $Balloon.Dispose()
}

while (!(test-connection 8.8.8.8 -Count 1 -Quiet)) {
	cls
	$Title = "NOT Connected to the Internet"
	$Message = $Title
	Write-Host $Messsage -ForegroundColor Red -BackgroundColor Blue
	Show-NotifyBalloon 'Warning' $Title $Message
	sleep 2
	cls
	$Message = "Please wait a while until the Internet Connection will be established ..."
	Write-Host $Message -ForegroundColor Cyan -BackgroundColor Blue
	Show-NotifyBalloon 'Warning' $Title $Message
	sleep 2
}
cls
$SSID = (get-netconnectionProfile).Name.Trim()
$WAN_IP = (Invoke-WebRequest ifconfig.me/ip).Content.Trim()
$LAN_IP = (Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE) | %{$_.ipaddress[0]}
$Title = "$SSID : Connected to the Internet $CopyRight"
Write-Host "`r`n   Connected to the Internet over Wi-Fi: $SSID" -ForegroundColor Yellow -BackgroundColor Blue
Write-Host "   LAN IP : $LAN_IP" -ForegroundColor Yellow -BackgroundColor Blue
Write-Host "   WAN IP : $WAN_IP" -ForegroundColor Yellow -BackgroundColor Blue
$Message = ("LAN IP : $LAN_IP" + [System.Environment]::NewLine +"WAN IP : $WAN_IP" + [System.Environment]::NewLine + "Connected to the Internet over Wi-Fi: $SSID")
Show-NotifyBalloon  'Info' $Title $Message
#------------------------------------------------------------------------------------------------------------------------------------------------------------------
$GitHub_IPTV_Channels_Folder = "$PSScriptRoot\GitHub_IPTV_Channels\"
If ((Test-Path -Path $GitHub_IPTV_Channels_Folder) -eq 0) { New-Item -Path $GitHub_IPTV_Channels_Folder -ItemType Directory | Out-Null }

$url="https://iptv-org.github.io/iptv/channels.json"
$JSON_File = $GitHub_IPTV_Channels_Folder +"\iptv-channels.json"
$M3U_File  = $GitHub_IPTV_Channels_Folder +"\iptv-channels.m3u" 
$start_time = Get-Date

Try {
	cls
	Write-Host "`r`n          Please Wait A While ... Trying To connect To IPTV Resources ..." -ForegroundColor Yellow -BackgroundColor Blue
    (New-Object System.Net.WebClient).DownloadFile($url,$JSON_File)
<#
	$http_request = New-Object -ComObject Msxml2.ServerXMLHTTP
	$http_request.open('GET', $url, $false)
	$http_request.send()
	cls
	Write-Host "`r`n  Sever Web Response : "$http_request.status - $http_request.statusText -ForegroundColor Yellow -BackgroundColor Blue
#>
	}
Catch
	{
		Write-Host "Message: $($_.Exception.Message)" -ForegroundColor Red -BackgroundColor Blue
		Exit
	}
<#
$BS = New-Object -ComObject ADODB.Stream
$BS.type = 1
$BS.open()
$BS.Write($http_request.ResponseBody)
$BS.SaveToFile($JSON_File,2)
#>
$jsonContent = GC $JSON_File | ConvertFrom-Json
$Channel_Count = $jsonContent.Name.count
##################################### Building M3U File ###########################################
cls
Write-Host "`r`n           Please Wait A While ... Building M3U File Is In Progress ..." -ForegroundColor Yellow -BackgroundColor Blue
"#EXTM3U" | Out-File -FilePath $M3U_File -Encoding utf8
for ($i=0; $i -lt $Channel_Count; $i++) {
	'#EXTINF:-1,'+ $jsonContent.name[$i] | Out-File -FilePath $M3U_File -Encoding utf8 -Append
	$jsonContent.url[$i] | Out-File -FilePath $M3U_File -Encoding utf8 -Append
}
##################################### Building M3U File ###########################################
$Elapsed_Time = "$((Get-Date).Subtract($start_time).Minutes) Minutes(M) : $((Get-Date).Subtract($start_time).Seconds) Secondes(s)"
cls
        Write-Output "`r`n           Running Script Time Taken is : $Elapsed_Time"
If ((Test-Path -path $M3U_File) -eq 1) {
	$shell = new-object -comobject "WScript.Shell"
	$Answer = $shell.popup("Running Script Time Taken is : $Elapsed_Time `r`nDo you want to launch the m3u file ?",0,"$Title",4+32+4096)
	If ($Answer -eq 6) {
		Write-Host "                      OK We are Starting the m3u File !" -ForegroundColor Yellow -BackgroundColor Blue
        Start $M3U_File
	} else {
		Write-Host "                Script Aborted without launching the m3u file !" -ForegroundColor Yellow -BackgroundColor Blue
	}
}
For any update or modification, you can found it here

Re: tv

Posted: 29 Apr 2021 04:28
by krypton
That is very cool and worked like a charm! Will this only work for that github page or can it possibly work for other sites?