Batch program to add text to url

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
tea
Posts: 8
Joined: 14 Oct 2019 11:58

Batch program to add text to url

#1 Post by tea » 14 Oct 2019 12:14

Hi Guys

Im not sure if Im in the right site or not.

Im looking for a batch program to automate a url link that changes.

I have this url format that does not change http://name.com:8080/username/password/30356

and need to have this format:http://name.com:8080/get.php?username=u ... d&type=gif

The 30356 is not needed.

Is there any kind of batch program that I can paste ----http://name.com:8080/username/password/30356 at a prompt and have an output of

http://name.com:8080/get.php?username=u ... d&type=gif

Thank you for your time

penpen
Expert
Posts: 1991
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Batch program to add text to url

#2 Post by penpen » 15 Oct 2019 04:25

This might help you:

Code: Select all

@echo off
setlocal enableExtensions enableDelayedExpansion
:: uri encoded input of form:  http://name.com:8080/<username>/<password>/30356
set "input="
set /p "input="

:: 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=<username>&password=<password>&...&type=gif
set "output="
for /f "tokens=1-5 delims=/" %%a in ("!input!") do (
	set "output=%%~a//%%~b/get.php?username=%%~c&password=%%~d&...&type=gif"
)

echo(!output!

goto :eof
penpen

tea
Posts: 8
Joined: 14 Oct 2019 11:58

Re: Batch program to add text to url

#3 Post by tea » 15 Oct 2019 08:17

Thank you wow

You don't know how long I was trying just to make the batch just print a "&" symbol :roll: .....

The program works as advertised.

Is it possible to put the output to the clipboard?

Thank you again

Tea

penpen
Expert
Posts: 1991
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Batch program to add text to url

#4 Post by penpen » 15 Oct 2019 19:08

The tool clip.exe could be used for that:

Code: Select all

@echo off
setlocal enableExtensions enableDelayedExpansion
:: uri encoded input of form:  http://name.com:8080/<username>/<password>/30356
set "input="
set /p "input="

:: 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=<username>&password=<password>&...&type=gif
set "output="
for /f "tokens=1-5 delims=/" %%a in ("!input!") do (
	set "output=%%~a//%%~b/get.php?username=%%~c&password=%%~d&...&type=gif"
	@(
		cmd /E:ON /V:ON /cecho(!output!
	)|clip
)


goto :eof
penpen

tea
Posts: 8
Joined: 14 Oct 2019 11:58

Re: Batch program to add text to url

#5 Post by tea » 13 Dec 2019 19:57

Any thoughts on my live tv program?


: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=gif
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

Post Reply