downloading videos from different video sites in i

2019-06-08 08:53发布

问题:

in my application,user can download and play videos from different video sites like bofunk.com,dailymotion.com,youtube.com,metacafe.com,stupid videos.com etc.what is the idea behind downloading videos from different sites.i implemented a method and is working for some sites.That is by generating a downloadable url from the html string.But this same method is not working for other sites.Can anyone guide me o this?thanks in advance.This is what i have tried and is working for bofunk.com

`-(BOOL)searchForVideoInBOFUNKHTML:(NSString*)htmlString;
{
    NSString *strHTML=[NSString stringWithFormat:@"%@",htmlString];       
    NSString *newString; 

    if ([htmlString rangeOfString:@"id=\"vidplaya\""].location == NSNotFound) 
    {
        return  false;
    }   
    else
    {
        htmlString = [strHTML substringFromIndex:[htmlString rangeOfString:@"id=\"vidplaya\""].location];

        htmlString=  [htmlString stringByReplacingOccurrencesOfString:[htmlString substringFromIndex:100]
                                                        withString:@""];



            newString =[htmlString stringByReplacingOccurrencesOfString:[htmlString substringFromIndex:[htmlString rangeOfString:@"quality"].location] withString:@""];
        NSLog(@"%@",newString);

            newString = [[[newString substringFromIndex:[newString rangeOfString:@"/"].location] substringFromIndex:3] stringByReplacingOccurrencesOfString:@"\"" withString:@""];
         NSLog(@"%@",newString);

            newString = [newString stringByReplacingOccurrencesOfString:@" " withString:@""];
         NSLog(@"%@",newString);


            embededURL = [[NSString alloc] initWithFormat:@"http://media.bofunk.com/media/flvs/%@.flv",newString]; 

        NSLog(@"%@",embededURL);
            return true;

    }
    return  false;

}

`But is not working for sites like dailymotion.com.Is it an issue related to any kind of encryption on these sites?

回答1:

Dailymotion provides an API for iOS. So you can use it. But don't expect it to work with other services. You will have to implement them all one by one. Some of them might be impossible to use with external software.



回答2:

Here is discussion about how to download MP4 data from YouTube.

There are sample projects and fine way to download. This may help you.

Save Youtube video to iPhone in the app