1

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?

iOS Developer
  • 1,713
  • 2
  • 16
  • 47
  • Did you verify that the URLs created by your program are actually correct? e.g. take the URL generated for dailymotion, paste it into a browser and look at the result – nohillside Aug 04 '12 at 10:30
  • @patrix yes i checked.the url generated for bofunk.com is pasted on browser and is directly downloading the video.But when tried with the url generated for dailymotion.com,it is just playing the video on the browser.What may be the reason? – iOS Developer Aug 04 '12 at 10:45
  • It's the wrong URL :-) Or dailymotion.com doesn't allow downloads. Or you need to look at the HTML code for the dailymotion.com page to figure out the direct URL for the video. Maybe they even offer an API to access videos directly. – nohillside Aug 04 '12 at 11:24

2 Answers2

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.

olly_uk
  • 10,711
  • 3
  • 38
  • 45
Adam
  • 24,901
  • 8
  • 59
  • 74
1

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

Community
  • 1
  • 1
Feel Physics
  • 2,773
  • 4
  • 22
  • 36