Sign in to follow this  
Followers 0
Carlo84

Tip: getting parameters from url.

7 posts in this topic

Hi , all my apologizes if this is not the correct forum to post this.

But i whas just browsing around looking for some info about getting the download url for youtube videos and noticed most of the scripts are broken cause the urls are read in wrong.

When trying to read an urls parameters you cannot use stringbetween and the likes of that, using a function like that means you are looking for something between the parameter and the parameter after that.

Now the issue with PHP GET method is that there is no specific order in witch these parameters must be passed, so if the order is changed your script will break.

right an url with get parameters looks like http://Somedomain.com/somepage.php?FirstParameter=FirstResult&MoreParameters=MoreResults

So just split your sting to get all parameters.

Lets not forget about bookmarks neither. http://Somedomain.com/somepage.php?FirstParameter=FirstResult&MoreParameters=MoreResults#Bookmark

cause we dont want the last parameter to be corrupted cause some bookmark.

Heres an example on getting a video ID from a youtube url. but hey it works on any url.

Func getVidIDfromURL($url = "http://www.youtube.com/watch?v=da0eaiZ0CKw&feature=related")
    $url = StringSplit($url, "&?#")
    Local $VidID = ""
    Local $i = 1
    While $i < $url[0] + 1
        If StringLeft($url[$i], 2) = "v=" Then
            $url = StringSplit($url[$i], "=")
            If $url[0] = 2 Then $VidID = $url[2]
            ExitLoop
        EndIf
        $i = $i + 1
    WEnd
    If $VidID = "" Then
        Return SetError(1, 0, 0)
    Else
        Return $VidID
    EndIf
EndFunc   ;==>getVidIDfromURL

or heres an example without splitting the string twice.

Func getVidIDfromURL($url = "http://www.youtube.com/watch?v=da0eaiZ0CKw&feature=related")
    $url = StringSplit($url, "&?#")
    Local $VidID = ""
    Local $i = 1
    While $i < $url[0] + 1
        If StringLeft($url[$i], 2) = "v=" Then
            $VidID = StringReplace ($url[$i], "v=", "")
            ExitLoop
        EndIf
        $i = $i + 1
    WEnd
    If $VidID = "" Then
        Return SetError(1, 0, 0)
    Else
        Return $VidID
    EndIf
EndFunc   ;==>getVidIDfromURL

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

See this Post , it can help you ! Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

See this Post , it can help you ! Posted Image

Thanks wakillon, i think i should have posted this in examples, instead of help and support.

Its just an problem i seen allot in peoples scripts on the forum and figured id post an example for getting url parameters.

Thanks anyways ;) havent seen yours yet, might be usefull making my player.

Share this post


Link to post
Share on other sites

A player !

So See this post for a youtube player ! Posted Image


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

haha you got it all :) your stuff works perfect ;)

Yes im trying to make it something similar to Media Player Classic. but then for youtube and with options to save video/audio. and m3u support.

Thanks !

Use the Forum search for media player Posted Image


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

haha you got it all :) your stuff works perfect ;)

Yes im trying to make it something similar to Media Player Classic. but then for youtube and with options to save video/audio. and m3u support.

it's not an autoit script, but check out Tversity media server. is great for changing format on the fly

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0