[38960] | 1 | |
---|
[38961] | 2 | import sys |
---|
[38960] | 3 | import re |
---|
[38961] | 4 | from net import Net |
---|
[38960] | 5 | |
---|
[38961] | 6 | class NosvideoResolver(object): |
---|
[38960] | 7 | name = "nosvideo" |
---|
| 8 | domains = ["nosvideo.com", "noslocker.com"] |
---|
| 9 | pattern = '(?://|\.)(nosvideo.com|noslocker.com)/(?:\?v\=|embed/|.+?\u=)?([0-9a-zA-Z]+)' |
---|
| 10 | |
---|
| 11 | def __init__(self): |
---|
[38961] | 12 | self.net = Net() |
---|
| 13 | url = str(sys.argv[1]) |
---|
| 14 | host = self.get_host_and_id(url)[0] |
---|
| 15 | media_id = self.get_host_and_id(url)[1] |
---|
[38960] | 16 | |
---|
[38961] | 17 | return self.get_media_url(host, media_id) |
---|
| 18 | |
---|
| 19 | def get_host_and_id(self, url): |
---|
| 20 | r = re.search(self.pattern, url, re.I) |
---|
| 21 | if r: |
---|
| 22 | return r.groups() |
---|
| 23 | else: |
---|
| 24 | return False |
---|
| 25 | |
---|
[38960] | 26 | def get_media_url(self, host, media_id): |
---|
| 27 | web_url = self.get_url(host, media_id) |
---|
| 28 | |
---|
| 29 | html = self.net.http_GET(web_url).content |
---|
| 30 | |
---|
| 31 | if 'File Not Found' in html: |
---|
| 32 | raise ResolverError('File Not Found') |
---|
| 33 | |
---|
| 34 | web_url = 'http://nosvideo.com/vj/video.php?u=%s&w=&h=530' % media_id |
---|
| 35 | |
---|
| 36 | html = self.net.http_GET(web_url).content |
---|
| 37 | |
---|
| 38 | smil_url = re.compile('\':\'(.+?)\'').findall(html) |
---|
| 39 | smil_url = [i for i in smil_url if '.smil' in i][0] |
---|
| 40 | |
---|
| 41 | html = self.net.http_GET(smil_url).content |
---|
| 42 | |
---|
| 43 | streamer = re.findall('base\s*=\s*"(.+?)"', html)[0] |
---|
| 44 | playpath = re.findall('src\s*=\s*"(.+?)"', html)[0] |
---|
| 45 | |
---|
| 46 | stream_url = '%s playpath=%s' % (streamer, playpath) |
---|
| 47 | |
---|
[38961] | 48 | print stream_url |
---|
[38960] | 49 | |
---|
| 50 | def get_url(self, host, media_id): |
---|
| 51 | return 'http://nosvideo.com/%s' % media_id |
---|
| 52 | |
---|
[38961] | 53 | sys.stdout = NosvideoResolver() |
---|
| 54 | |
---|