Home Backend Development PHP Tutorial Get the final address of youku video_PHP tutorial

Get the final address of youku video_PHP tutorial

Jul 20, 2016 am 11:16 AM
error private static address Obtain video

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

<?php

 

 

class YoukuFlv{

 

    static private $error   =   "";

    static private $result  =   array();

 

    static public function getYoukuFlv($url){

        //从url获取youkuid

        if(! $id    =   self::getYoukuId($url)){

            return false;

        }

        //获取youku视频详细信息

        $content    =   self::get_curl_contents( "http://v.youku.com/player/getPlayList/VideoIDS/".$id );

        $data   =   json_decode($content);

        if(!isset($data->data[0]->streamfileids)){

            self::$error    =   "Cannot find this video";

            return false;

        }

        foreach($data->data[0]->streamfileids AS $k=>$v){

            if($k == 'flv' || $k == 'mp4'){        

                //sid

                $sid=   self::getSid();

                //fileid

                $fileid =   self::getfileid($v,$data->data[0]->seed);

                $one=($data->data[0]->segs->$k);

                self::$result[$k]   = "http://f.youku.com/player/getFlvPath/sid/{$sid}_00/st/{$k}/fileid/{$fileid}?K={$one[0]->k}";

            }

        }

        if(empty(self::$result)){

            self::$error    =   "THIS VIOD IS NOT IN MP4 OR FLV FORMAT";

            return false;

        }else{

            return true;

        }

    }

    static public function error(){

        return self::$error;

    }

 

    static public function result(){

        return self::$result;

    }

 

    static private function getYoukuId($url){      

        //url 不能为空

        if($url == "" || substr($url , 0 , 29) != "http://v.youku.com/v_show/id_"){

            self::$error    =   "URL IS ERROR";

            return false;

        }

        return substr($url , 29 , -5);     

    }

 

    static private function get_curl_contents($url, $second = 5){

        if(!function_exists('curl_init')) die('php.ini未开启php_curl.dll');

        $c = curl_init();

        curl_setopt($c,CURLOPT_URL,$url);

        $UserAgent=$_SERVER['HTTP_USER_AGENT'];

        curl_setopt($c,CURLOPT_USERAGENT,$UserAgent);

        curl_setopt($c,CURLOPT_HEADER,0);

        curl_setopt($c,CURLOPT_TIMEOUT,$second);

        curl_setopt($c,CURLOPT_RETURNTRANSFER, true);

        $cnt = curl_exec($c);

        curl_close($c);

        return $cnt;

    }

    static private function getSid() {

        $sid = time().(rand(0,9000)+10000);

        return $sid;

    }

    static private function getfileid($fileId,$seed) {

        $mixed = self::getMixString($seed);

        $ids = explode("*",$fileId);

        unset($ids[count($ids)-1]);

        $realId = "";

        for ($i=0;$i < count($ids);++$i) {

            $idx = $ids[$i];

            $realId .= substr($mixed,$idx,1);

        }

        return $realId;

    }

    static private function getMixString($seed) {

        $mixed = "";

        $source = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/\\:._-1234567890";

        $len = strlen($source);

        for($i=0;$i< $len;++$i){

            $seed = ($seed * 211 + 30031) % 65536;

            $index = ($seed / 65536 * strlen($source));

            $c = substr($source,$index,1);

            $mixed .= $c;

            $source = str_replace($c, "",$source);

        }

        return $mixed;

    }

}

 

 

 

if(YoukuFlv::getYoukuFlv("http://v.youku.com/v_show/id_XNjEyOTE4NTEy_ev_1.html")){

    print_r( YoukuFlv::result() );

}else{

    echo YoukuFlv::error();

}

 

?>

Copy after login

 还有一种 方法

http://player.youku.com/player.php/sid/XMjI0MDIwNDc2/v.swf

http://player.youku.com/player.php/sid/{$id}/v.swf

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/440119.htmlTechArticle?phpclass YoukuFlv{static private $error="";static private $result=array();static public function getYoukuFlv($url){//从url获取youkuidif(! $id=self::getYoukuId($url)){return fal...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Is it infringing to post other people's videos on Douyin? How does it edit videos without infringement? Is it infringing to post other people's videos on Douyin? How does it edit videos without infringement? Mar 21, 2024 pm 05:57 PM

With the rise of short video platforms, Douyin has become an indispensable part of everyone's daily life. On TikTok, we can see interesting videos from all over the world. Some people like to post other people’s videos, which raises a question: Is Douyin infringing upon posting other people’s videos? This article will discuss this issue and tell you how to edit videos without infringement and how to avoid infringement issues. 1. Is it infringing upon Douyin’s posting of other people’s videos? According to the provisions of my country's Copyright Law, unauthorized use of the copyright owner's works without the permission of the copyright owner is an infringement. Therefore, posting other people’s videos on Douyin without the permission of the original author or copyright owner is an infringement. 2. How to edit a video without infringement? 1. Use of public domain or licensed content: Public

How to make money from posting videos on Douyin? How can a newbie make money on Douyin? How to make money from posting videos on Douyin? How can a newbie make money on Douyin? Mar 21, 2024 pm 08:17 PM

Douyin, the national short video platform, not only allows us to enjoy a variety of interesting and novel short videos in our free time, but also gives us a stage to show ourselves and realize our values. So, how to make money by posting videos on Douyin? This article will answer this question in detail and help you make more money on TikTok. 1. How to make money from posting videos on Douyin? After posting a video and gaining a certain amount of views on Douyin, you will have the opportunity to participate in the advertising sharing plan. This income method is one of the most familiar to Douyin users and is also the main source of income for many creators. Douyin decides whether to provide advertising sharing opportunities based on various factors such as account weight, video content, and audience feedback. The TikTok platform allows viewers to support their favorite creators by sending gifts,

How to publish Xiaohongshu video works? What should I pay attention to when posting videos? How to publish Xiaohongshu video works? What should I pay attention to when posting videos? Mar 23, 2024 pm 08:50 PM

With the rise of short video platforms, Xiaohongshu has become a platform for many people to share their lives, express themselves, and gain traffic. On this platform, publishing video works is a very popular way of interaction. So, how to publish Xiaohongshu video works? 1. How to publish Xiaohongshu video works? First, make sure you have a video content ready to share. You can use your mobile phone or other camera equipment to shoot, but you need to pay attention to the image quality and sound clarity. 2. Edit the video: In order to make the work more attractive, you can edit the video. You can use professional video editing software, such as Douyin, Kuaishou, etc., to add filters, music, subtitles and other elements. 3. Choose a cover: The cover is the key to attracting users to click. Choose a clear and interesting picture as the cover to attract users to click on it.

How to post videos on Weibo without compressing the image quality_How to post videos on Weibo without compressing the image quality How to post videos on Weibo without compressing the image quality_How to post videos on Weibo without compressing the image quality Mar 30, 2024 pm 12:26 PM

1. First open Weibo on your mobile phone and click [Me] in the lower right corner (as shown in the picture). 2. Then click [Gear] in the upper right corner to open settings (as shown in the picture). 3. Then find and open [General Settings] (as shown in the picture). 4. Then enter the [Video Follow] option (as shown in the picture). 5. Then open the [Video Upload Resolution] setting (as shown in the picture). 6. Finally, select [Original Image Quality] to avoid compression (as shown in the picture).

Where to get Google security code Where to get Google security code Mar 30, 2024 am 11:11 AM

Google Authenticator is a tool used to protect the security of user accounts, and its key is important information used to generate dynamic verification codes. If you forget the key of Google Authenticator and can only verify it through the security code, then the editor of this website will bring you a detailed introduction on where to get the Google security code. I hope it can help you. If you want to know more Users please continue reading below! First open the phone settings and enter the settings page. Scroll down the page and find Google. Go to the Google page and click on Google Account. Enter the account page and click View under the verification code. Enter your password or use your fingerprint to verify your identity. Obtain a Google security code and use the security code to verify your Google identity.

Where can I change my Meituan address? Meituan address modification tutorial! Where can I change my Meituan address? Meituan address modification tutorial! Mar 15, 2024 pm 04:07 PM

1. Where can I change my Meituan address? Meituan address modification tutorial! Method (1) 1. Enter Meituan My Page and click Settings. 2. Select personal information. 3. Click the shipping address again. 4. Finally, select the address you want to modify, click the pen icon on the right side of the address, and modify it. Method (2) 1. On the homepage of the Meituan app, click Takeout, then click More Functions after entering. 2. In the More interface, click Manage Address. 3. In the My Shipping Address interface, select Edit. 4. Modify them one by one according to your needs, and finally click to save the address.

Two solutions for sharing edge browser web videos with no sound Two solutions for sharing edge browser web videos with no sound Mar 14, 2024 pm 02:22 PM

Many users like to watch videos on the browser. If there is no sound when watching web videos on the edge browser, how to solve the problem? This problem is not difficult. Next, let me tell you how to fix the problem of no sound in edge browser web videos. There is no sound in edge browser web videos? Method 1: 1. First, check the top tab of the edge browser. 2. There is a "Sound Button" on the left side of the tab, make sure it is not muted. Method 2: 1. If it is confirmed that the sound is not muted, it may be a sound setting problem. 2. You can right-click the sound device in the lower right corner and select "Open Volume Synthesizer" 3. Open

Douyin 15 seconds is too short and I want to extend it. How can I extend it? How to make a video longer than 15 seconds? Douyin 15 seconds is too short and I want to extend it. How can I extend it? How to make a video longer than 15 seconds? Mar 22, 2024 pm 08:11 PM

With the popularity of Douyin, more and more people like to share their lives, talents and creativity on this platform. Douyin's 15-second limit makes many users feel that it is not enjoyable enough and hope to extend the video duration. So, how can you extend the video duration on Douyin? 1. Douyin 15 seconds is too short and I want to extend it. How can I extend it? 1. The most convenient way to shoot multiple videos and splice them is to record multiple 15-second videos, and then use the editing function of Douyin to combine them. When recording, make sure to leave some blank space at the beginning and end of each video for later splicing. The length of the spliced ​​video can be several minutes, but this may cause the video screen to switch too frequently, affecting the viewing experience. 2. Use Douyin special effects and stickers Douyin provides a series of special effects

See all articles