1 | ''' |
---|
2 | Nosvideo urlresolver plugin |
---|
3 | Copyright (C) 2013 Vinnydude |
---|
4 | |
---|
5 | This program is free software: you can redistribute it and/or modify |
---|
6 | it under the terms of the GNU General Public License as published by |
---|
7 | the Free Software Foundation, either version 3 of the License, or |
---|
8 | (at your option) any later version. |
---|
9 | |
---|
10 | This program is distributed in the hope that it will be useful, |
---|
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | GNU General Public License for more details. |
---|
14 | |
---|
15 | You should have received a copy of the GNU General Public License |
---|
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
17 | ''' |
---|
18 | |
---|
19 | import re |
---|
20 | from urlresolver import common |
---|
21 | from urlresolver.resolver import UrlResolver, ResolverError |
---|
22 | |
---|
23 | class NosvideoResolver(UrlResolver): |
---|
24 | name = "nosvideo" |
---|
25 | domains = ["nosvideo.com", "noslocker.com"] |
---|
26 | pattern = '(?://|\.)(nosvideo.com|noslocker.com)/(?:\?v\=|embed/|.+?\u=)?([0-9a-zA-Z]+)' |
---|
27 | |
---|
28 | def __init__(self): |
---|
29 | self.net = common.Net() |
---|
30 | |
---|
31 | def get_media_url(self, host, media_id): |
---|
32 | web_url = self.get_url(host, media_id) |
---|
33 | |
---|
34 | html = self.net.http_GET(web_url).content |
---|
35 | |
---|
36 | if 'File Not Found' in html: |
---|
37 | raise ResolverError('File Not Found') |
---|
38 | |
---|
39 | web_url = 'http://nosvideo.com/vj/video.php?u=%s&w=&h=530' % media_id |
---|
40 | |
---|
41 | html = self.net.http_GET(web_url).content |
---|
42 | |
---|
43 | smil_url = re.compile('\':\'(.+?)\'').findall(html) |
---|
44 | smil_url = [i for i in smil_url if '.smil' in i][0] |
---|
45 | |
---|
46 | html = self.net.http_GET(smil_url).content |
---|
47 | |
---|
48 | streamer = re.findall('base\s*=\s*"(.+?)"', html)[0] |
---|
49 | playpath = re.findall('src\s*=\s*"(.+?)"', html)[0] |
---|
50 | |
---|
51 | stream_url = '%s playpath=%s' % (streamer, playpath) |
---|
52 | |
---|
53 | return stream_url |
---|
54 | |
---|
55 | def get_url(self, host, media_id): |
---|
56 | return 'http://nosvideo.com/%s' % media_id |
---|
57 | |
---|