File size: 2,064 Bytes
e26fba6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Specialized;
using System.Web;
using System.Threading;
using HtmlAgilityPack;

namespace MovieTube.Client.Scraper
{
    public class Dwn : VideoScraperBase
    {
        protected override string OnScrape(string url, HtmlNode elem)
        {
            url = SubstringBetween(elem.InnerHtml, "un=\"", "\"");
            if (!url.StartsWith("http"))
                url = "http://" + url;
            return new Uri(url).AbsoluteUri;
        }

     
        public override string RootUrl
        {
            get { return "http://dwn.so/"; }
        }

        public override string ID
        {
            get { return ScrapperId.Dwn; }
        }

        public override string Title
        {
            get { return "Dwn"; }
        }

        public override ScraperRank Rank
        {
            get
            {
                return ScraperRank.Dwn;
            }
        }

        public override string SanitizeUrl(string url)
        {
            if (url.ToLower().Contains("dwn.so/xml/videolink"))
                return url;
            if (!url.ToLower().Contains("dwn.so/player/embed.php?v="))
                throw new Exception("Unknown format");
            var id =  SubstringBetween(url, "v=","&");
            url = String.Format("http://dwn.so/xml/videolink.php?v={0}", id);
            return url;
        }

        public override string GetFlashUrl(string url)
        {
            //http://dwn.so/v/DS1C4741A5
            if (url.ToLower().Contains("dwn.so/xml/"))
            {
                var id = SubstringBetween(url, "v=");
                url = String.Format("http://dwn.so/v/{0}", id);
            }
            return url;
        }

        //public override bool CanProcess(string url)
        //{
        //    if (base.CanProcess(url))
        //        return true;
        //    return url.ToLower().Contains("veoh");
        //}
    }
}