Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 2004
    Location
    London
    Posts
    2,163
    Tokens
    44
    Habbo
    HabbaJabba

    Latest Awards:

    Default PHP help needed!

    I'm kind of in a pickle at the moment! I have a PHP script here which converts an inputted YouTube URL into an MP4, although after it's converted it into the MP4, I would like it to finally convert into a tinyurl. I've tried but I really don't understand how I could do so, so if anyone could lend a hand, then I'd definitely be grateful!

    +rep to any help!

    PHP Code:
    <?php
    $youtube 
    $_GET['web'];
    function 
    getstring($string)
    {
        
    $pos strrpos($string"swfArgs")+11;
         
    $texto substr($string,$pos,strrpos(substr($string,$pos,strlen($string)), "additionalStatsHonorsUrl")-10);
            
    $replace = array(" ",'"',"_");
        
    $adata split(",",str_replace($replace,"",$texto));
        
    $vid_id split(":",$adata[2]);
        
    $lang split(":",$adata[7]);
        
    $code split(":",$adata[6]);
        
    $vidn1 strrpos($string"<title>")+7;
        
    $vidn2 strrpos(substr($string,$vidn1,-1), "</title>");
        
    $vidname substr($string,$vidn1,$vidn2);
        
    $web 'http://www.youtube.com/get_video?video_id='.$vid_id[1].'&hl='.$lang[1].'&t='.$code[1].'&fmt=18';
        echo 
    $web.'|'.$vidname;

    function 
    getPage($opts) {
            
    $ch curl_init($opts);
            
    curl_setopt($chCURLOPT_USERAGENT"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.12) Gecko/20070508 Firefox/1.5.0.12");
            
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
            
    curl_setopt($chCURLOPT_HEADER0);
            
    curl_setopt($chCURLOPT_FOLLOWLOCATION1);
            
    curl_setopt($chCURLOPT_AUTOREFERER1);
            
    curl_setopt($chCURLOPT_TIMEOUT5);
            
    $html curl_exec($ch);
            if(
    curl_errno($ch)) {
                
    $html "";
            }
            
    curl_close ($ch);
        return 
    getstring($html);
    }
    getPage($youtube);
    ?>
    PHP Code:
        $web 'http://www.youtube.com/get_video?video_id='.$vid_id[1].'&hl='.$lang[1].'&t='.$code[1].'&fmt=18';
        echo 
    $web.'|'.$vidname
    is the conversion that takes place, after this has happened, the tinyurl conversion needs to take place.

  2. #2
    Join Date
    May 2007
    Posts
    10,481
    Tokens
    3,140

    Latest Awards:

    Default

    Google made this easy:
    PHP Code:
    <?php
    function createTinyUrl($strURL) {
        
    $tinyurl file_get_contents("http://tinyurl.com/api-create.php?url=".$strURL);
        return 
    $tinyurl;
    }
    ?>
    PHP Code:
    <?php
    echo(createTinyUrl('http://www.richardcastera.com/2009/05/09/creating-a-tinyurl-with-tinyurl-api/'));
    ?>
    Chippiewill.


  3. #3
    Join Date
    Jul 2004
    Location
    London
    Posts
    2,163
    Tokens
    44
    Habbo
    HabbaJabba

    Latest Awards:

    Default

    Quote Originally Posted by Chippiewill View Post
    Google made this easy:
    PHP Code:
    <?php
    function createTinyUrl($strURL) {
        
    $tinyurl file_get_contents("http://tinyurl.com/api-create.php?url=".$strURL);
        return 
    $tinyurl;
    }
    ?>
    PHP Code:
    <?php
    echo(createTinyUrl('http://www.richardcastera.com/2009/05/09/creating-a-tinyurl-with-tinyurl-api/'));
    ?>
    I've tried this already but if I honestly don't know how to make the URL convert to a tinyURL AFTER converting to the MP4.

  4. #4
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Code:
    <?php
    echo createTinyUrl(getPage($youtube)); 
    ?>

  5. #5
    Join Date
    Jan 2006
    Location
    Kent
    Posts
    987
    Tokens
    0

    Default

    Can I ask what you're using to convert the video once you've downloaded it? FFMPEG? Looked into making one of these scripts a while ago.
    This is our situation and we're happy to be here,
    I wouldn't change this place for anything.


  6. #6
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    I really don't think he is converting it... I think he is just converting a standard URL / HTML into the MP4 download link for the given video... that's what I see in the code..

  7. #7
    Join Date
    Jan 2006
    Location
    Kent
    Posts
    987
    Tokens
    0

    Default

    Ah yeah, for some reason I read MP4 as MP3. My mistake
    This is our situation and we're happy to be here,
    I wouldn't change this place for anything.


  8. #8
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Haha, no problem. I thought you were thinking converting from what.. FLV isn't it? to MP4?

  9. #9
    Join Date
    Jul 2004
    Location
    London
    Posts
    2,163
    Tokens
    44
    Habbo
    HabbaJabba

    Latest Awards:

    Default

    You input a standard YouTube link and it gives you the MP4 link (FLV without &fmt=18).

    Thanks for the help btw, +rep given!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •