3v4l.org

run code in 300+ PHP versions simultaneously
<?php /***************************************************************** Created : 2014/03/25 Author : Mr. Khwanchai Kaewyos (LookHin) E-mail : khwanchai@gmail.com Website : www.LookHin.com Blog : www.unzeen.com Copyright (C) 2014, www.LookHin.com all rights reserved. *****************************************************************/ set_time_limit(0); $strMp4Folder = "./mp4/"; $strYoutubeDownloadUrl = " http://youtu.be/z-FNiOs_748 https://www.youtube.com/watch?v=gwKBOnMmpvU https://www.youtube.com/watch?v=dh7GMmRsQvA "; $arrYoutubeId = explode("\n", trim($strYoutubeDownloadUrl)); foreach ($arrYoutubeId as $key => $value) { // Get Youtube ID preg_match("/^(?:http(?:s)?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([^\?&\"'>]+)/", $value, $matches); $strYoutubeId = trim($matches[1]); print "Download => {$strYoutubeId}\n"; // Get Title Name $json = json_decode(file_get_contents("http://gdata.youtube.com/feeds/api/videos/{$strYoutubeId}?v=2&alt=json"),true); $strTitleName = iconv("UTF-8", "TIS-620", preg_replace("/[\"'\/:|\\\?\$\*%\-\+ ]/", "-", $json['entry']['title']['$t'])); // Get Mp4 Link $strMp4LinkTmp = ""; $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER,1); curl_setopt($ch, CURLOPT_URL,"http://www.youtube.com/watch?v={$strYoutubeId}"); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0"); curl_setopt($ch, CURLOPT_REFERER, "http://www.youtube.com/watch?v={$strYoutubeId}"); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); $result=curl_exec ($ch); curl_close ($ch); //print $result; preg_match_all("|url_encoded_fmt_stream_map\"\: \"(.*)\"|U",$result,$out, PREG_PATTERN_ORDER); $arrUrl = explode(',',$out[1][0]); foreach($arrUrl as $url){ if(substr_count(urldecode($url), "type=video/mp4") > 0 && substr_count(urldecode($url), "quality=medium") > 0){ $arrTmp = explode("\\u0026",urldecode($url)); $strUrl = ""; $strSig = ""; foreach($arrTmp as $strTmp){ if(substr_count(urldecode($strTmp), "url=") > 0){ $tmp = explode('url=',$strTmp); $strUrl = $tmp[1]; } if(substr_count(urldecode($strTmp), "sig=") > 0){ $tmp = explode('sig=',$strTmp); $strSig = $tmp[1]; } } $strMp4LinkTmp = $strUrl."&signature=".$strSig; //print $strMp4LinkTmp; } } // Download if($strMp4LinkTmp != ""){ //print $strMp4LinkTmp; copy($strMp4LinkTmp,"{$strMp4Folder}{$strTitleName}.mp4"); } } print "\n\nDownload Complete\n\n"; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 195
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 195
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 114, Position 2 = 184
Branch analysis from position: 114
2 jumps found. (Code = 78) Position 1 = 115, Position 2 = 184
Branch analysis from position: 115
2 jumps found. (Code = 46) Position 1 = 124, Position 2 = 133
Branch analysis from position: 124
2 jumps found. (Code = 43) Position 1 = 134, Position 2 = 183
Branch analysis from position: 134
2 jumps found. (Code = 77) Position 1 = 145, Position 2 = 179
Branch analysis from position: 145
2 jumps found. (Code = 78) Position 1 = 146, Position 2 = 179
Branch analysis from position: 146
2 jumps found. (Code = 43) Position 1 = 155, Position 2 = 162
Branch analysis from position: 155
2 jumps found. (Code = 43) Position 1 = 171, Position 2 = 178
Branch analysis from position: 171
1 jumps found. (Code = 42) Position 1 = 145
Branch analysis from position: 145
Branch analysis from position: 178
Branch analysis from position: 162
Branch analysis from position: 179
1 jumps found. (Code = 42) Position 1 = 114
Branch analysis from position: 114
Branch analysis from position: 179
Branch analysis from position: 183
Branch analysis from position: 133
Branch analysis from position: 184
2 jumps found. (Code = 43) Position 1 = 187, Position 2 = 194
Branch analysis from position: 187
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 194
Branch analysis from position: 184
Branch analysis from position: 195
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 195
filename:       /in/GsSNc
function name:  (null)
number of ops:  198
compiled vars:  !0 = $strMp4Folder, !1 = $strYoutubeDownloadUrl, !2 = $arrYoutubeId, !3 = $value, !4 = $key, !5 = $matches, !6 = $strYoutubeId, !7 = $json, !8 = $strTitleName, !9 = $strMp4LinkTmp, !10 = $ch, !11 = $result, !12 = $out, !13 = $arrUrl, !14 = $url, !15 = $arrTmp, !16 = $strUrl, !17 = $strSig, !18 = $strTmp, !19 = $tmp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'set_time_limit'
          1        SEND_VAL                                                 0
          2        DO_ICALL                                                 
   11     3        ASSIGN                                                   !0, '.%2Fmp4%2F'
   12     4        ASSIGN                                                   !1, '%0Ahttp%3A%2F%2Fyoutu.be%2Fz-FNiOs_748%0Ahttps%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DgwKBOnMmpvU%0Ahttps%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Ddh7GMmRsQvA%0A'
   17     5        INIT_FCALL                                               'explode'
          6        SEND_VAL                                                 '%0A'
          7        INIT_FCALL                                               'trim'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $23     
         10        SEND_VAR                                                 $23
         11        DO_ICALL                                         $24     
         12        ASSIGN                                                   !2, $24
   18    13      > FE_RESET_R                                       $26     !2, ->195
         14    > > FE_FETCH_R                                       ~27     $26, !3, ->195
         15    >   ASSIGN                                                   !4, ~27
   21    16        INIT_FCALL                                               'preg_match'
         17        SEND_VAL                                                 '%2F%5E%28%3F%3Ahttp%28%3F%3As%29%3F%3A%5C%2F%5C%2F%29%3F%28%3F%3Awww%5C.%29%3F%28%3F%3Ayoutu%5C.be%5C%2F%7Cyoutube%5C.com%5C%2F%28%3F%3A%28%3F%3Awatch%29%3F%5C%3F%28%3F%3A.%2A%26%29%3Fv%28%3F%3Ai%29%3F%3D%7C%28%3F%3Aembed%7Cv%7Cvi%7Cuser%29%5C%2F%29%29%28%5B%5E%5C%3F%26%22%27%3E%5D%2B%29%2F'
         18        SEND_VAR                                                 !3
         19        SEND_REF                                                 !5
         20        DO_ICALL                                                 
   22    21        INIT_FCALL                                               'trim'
         22        FETCH_DIM_R                                      ~30     !5, 1
         23        SEND_VAL                                                 ~30
         24        DO_ICALL                                         $31     
         25        ASSIGN                                                   !6, $31
   23    26        ROPE_INIT                                     3  ~34     'Download+%3D%3E+'
         27        ROPE_ADD                                      1  ~34     ~34, !6
         28        ROPE_END                                      2  ~33     ~34, '%0A'
         29        ECHO                                                     ~33
   25    30        INIT_FCALL                                               'json_decode'
         31        INIT_FCALL                                               'file_get_contents'
         32        ROPE_INIT                                     3  ~37     'http%3A%2F%2Fgdata.youtube.com%2Ffeeds%2Fapi%2Fvideos%2F'
         33        ROPE_ADD                                      1  ~37     ~37, !6
         34        ROPE_END                                      2  ~36     ~37, '%3Fv%3D2%26alt%3Djson'
         35        SEND_VAL                                                 ~36
         36        DO_ICALL                                         $39     
         37        SEND_VAR                                                 $39
         38        SEND_VAL                                                 <true>
         39        DO_ICALL                                         $40     
         40        ASSIGN                                                   !7, $40
   26    41        INIT_FCALL_BY_NAME                                       'iconv'
         42        SEND_VAL_EX                                              'UTF-8'
         43        SEND_VAL_EX                                              'TIS-620'
         44        INIT_FCALL                                               'preg_replace'
         45        SEND_VAL                                                 '%2F%5B%22%27%5C%2F%3A%7C%5C%5C%3F%24%5C%2A%25%5C-%5C%2B+%5D%2F'
         46        SEND_VAL                                                 '-'
         47        FETCH_DIM_R                                      ~42     !7, 'entry'
         48        FETCH_DIM_R                                      ~43     ~42, 'title'
         49        FETCH_DIM_R                                      ~44     ~43, '%24t'
         50        SEND_VAL                                                 ~44
         51        DO_ICALL                                         $45     
         52        SEND_VAR_NO_REF_EX                                       $45
         53        DO_FCALL                                      0  $46     
         54        ASSIGN                                                   !8, $46
   28    55        ASSIGN                                                   !9, ''
   29    56        INIT_FCALL_BY_NAME                                       'curl_init'
         57        DO_FCALL                                      0  $49     
         58        ASSIGN                                                   !10, $49
   30    59        INIT_FCALL_BY_NAME                                       'curl_setopt'
         60        SEND_VAR_EX                                              !10
         61        FETCH_CONSTANT                                   ~51     'CURLOPT_HEADER'
         62        SEND_VAL_EX                                              ~51
         63        SEND_VAL_EX                                              1
         64        DO_FCALL                                      0          
   31    65        INIT_FCALL_BY_NAME                                       'curl_setopt'
         66        SEND_VAR_EX                                              !10
         67        FETCH_CONSTANT                                   ~53     'CURLOPT_URL'
         68        SEND_VAL_EX                                              ~53
         69        NOP                                                      
         70        FAST_CONCAT                                      ~54     'http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D', !6
         71        SEND_VAL_EX                                              ~54
         72        DO_FCALL                                      0          
   32    73        INIT_FCALL_BY_NAME                                       'curl_setopt'
         74        SEND_VAR_EX                                              !10
         75        FETCH_CONSTANT                                   ~56     'CURLOPT_USERAGENT'
         76        SEND_VAL_EX                                              ~56
         77        SEND_VAL_EX                                              'Mozilla%2F5.0+%28Windows+NT+6.1%3B+WOW64%3B+rv%3A19.0%29+Gecko%2F20100101+Firefox%2F19.0'
         78        DO_FCALL                                      0          
   33    79        INIT_FCALL_BY_NAME                                       'curl_setopt'
         80        SEND_VAR_EX                                              !10
         81        FETCH_CONSTANT                                   ~58     'CURLOPT_REFERER'
         82        SEND_VAL_EX                                              ~58
         83        NOP                                                      
         84        FAST_CONCAT                                      ~59     'http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D', !6
         85        SEND_VAL_EX                                              ~59
         86        DO_FCALL                                      0          
   34    87        INIT_FCALL_BY_NAME                                       'curl_setopt'
         88        SEND_VAR_EX                                              !10
         89        FETCH_CONSTANT                                   ~61     'CURLOPT_RETURNTRANSFER'
         90        SEND_VAL_EX                                              ~61
         91        SEND_VAL_EX                                              1
         92        DO_FCALL                                      0          
   35    93        INIT_FCALL_BY_NAME                                       'curl_exec'
         94        SEND_VAR_EX                                              !10
         95        DO_FCALL                                      0  $63     
         96        ASSIGN                                                   !11, $63
   36    97        INIT_FCALL_BY_NAME                                       'curl_close'
         98        SEND_VAR_EX                                              !10
         99        DO_FCALL                                      0          
   38   100        INIT_FCALL                                               'preg_match_all'
        101        SEND_VAL                                                 '%7Curl_encoded_fmt_stream_map%22%5C%3A+%22%28.%2A%29%22%7CU'
        102        SEND_VAR                                                 !11
        103        SEND_REF                                                 !12
        104        SEND_VAL                                                 1
        105        DO_ICALL                                                 
   39   106        INIT_FCALL                                               'explode'
        107        SEND_VAL                                                 '%2C'
        108        FETCH_DIM_R                                      ~67     !12, 1
        109        FETCH_DIM_R                                      ~68     ~67, 0
        110        SEND_VAL                                                 ~68
        111        DO_ICALL                                         $69     
        112        ASSIGN                                                   !13, $69
   40   113      > FE_RESET_R                                       $71     !13, ->184
        114    > > FE_FETCH_R                                               $71, !14, ->184
   41   115    >   INIT_FCALL                                               'substr_count'
        116        INIT_FCALL                                               'urldecode'
        117        SEND_VAR                                                 !14
        118        DO_ICALL                                         $72     
        119        SEND_VAR                                                 $72
        120        SEND_VAL                                                 'type%3Dvideo%2Fmp4'
        121        DO_ICALL                                         $73     
        122        IS_SMALLER                                       ~74     0, $73
        123      > JMPZ_EX                                          ~74     ~74, ->133
        124    >   INIT_FCALL                                               'substr_count'
        125        INIT_FCALL                                               'urldecode'
        126        SEND_VAR                                                 !14
        127        DO_ICALL                                         $75     
        128        SEND_VAR                                                 $75
        129        SEND_VAL                                                 'quality%3Dmedium'
        130        DO_ICALL                                         $76     
        131        IS_SMALLER                                       ~77     0, $76
        132        BOOL                                             ~74     ~77
        133    > > JMPZ                                                     ~74, ->183
   42   134    >   INIT_FCALL                                               'explode'
        135        SEND_VAL                                                 '%5Cu0026'
        136        INIT_FCALL                                               'urldecode'
        137        SEND_VAR                                                 !14
        138        DO_ICALL                                         $78     
        139        SEND_VAR                                                 $78
        140        DO_ICALL                                         $79     
        141        ASSIGN                                                   !15, $79
   43   142        ASSIGN                                                   !16, ''
   44   143        ASSIGN                                                   !17, ''
   45   144      > FE_RESET_R                                       $83     !15, ->179
        145    > > FE_FETCH_R                                               $83, !18, ->179
   46   146    >   INIT_FCALL                                               'substr_count'
        147        INIT_FCALL                                               'urldecode'
        148        SEND_VAR                                                 !18
        149        DO_ICALL                                         $84     
        150        SEND_VAR                                                 $84
        151        SEND_VAL                                                 'url%3D'
        152        DO_ICALL                                         $85     
        153        IS_SMALLER                                               0, $85
        154      > JMPZ                                                     ~86, ->162
   47   155    >   INIT_FCALL                                               'explode'
        156        SEND_VAL                                                 'url%3D'
        157        SEND_VAR                                                 !18
        158        DO_ICALL                                         $87     
        159        ASSIGN                                                   !19, $87
   48   160        FETCH_DIM_R                                      ~89     !19, 1
        161        ASSIGN                                                   !16, ~89
   50   162    >   INIT_FCALL                                               'substr_count'
        163        INIT_FCALL                                               'urldecode'
        164        SEND_VAR                                                 !18
        165        DO_ICALL                                         $91     
        166        SEND_VAR                                                 $91
        167        SEND_VAL                                                 'sig%3D'
        168        DO_ICALL                                         $92     
        169        IS_SMALLER                                               0, $92
        170      > JMPZ                                                     ~93, ->178
   51   171    >   INIT_FCALL                                               'explode'
        172        SEND_VAL                                                 'sig%3D'
        173        SEND_VAR                                                 !18
        174        DO_ICALL                                         $94     
        175        ASSIGN                                                   !19, $94
   52   176        FETCH_DIM_R                                      ~96     !19, 1
        177        ASSIGN                                                   !17, ~96
   45   178    > > JMP                                                      ->145
        179    >   FE_FREE                                                  $83
   56   180        CONCAT                                           ~98     !16, '%26signature%3D'
        181        CONCAT                                           ~99     ~98, !17
        182        ASSIGN                                                   !9, ~99
   40   183    > > JMP                                                      ->114
        184    >   FE_FREE                                                  $71
   62   185        IS_NOT_EQUAL                                             !9, ''
        186      > JMPZ                                                     ~101, ->194
   64   187    >   INIT_FCALL                                               'copy'
        188        SEND_VAR                                                 !9
        189        ROPE_INIT                                     3  ~103    !0
        190        ROPE_ADD                                      1  ~103    ~103, !8
        191        ROPE_END                                      2  ~102    ~103, '.mp4'
        192        SEND_VAL                                                 ~102
        193        DO_ICALL                                                 
   18   194    > > JMP                                                      ->14
        195    >   FE_FREE                                                  $26
   67   196        ECHO                                                     '%0A%0ADownload+Complete%0A%0A'
   68   197      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.81 ms | 1412 KiB | 38 Q