Ejemplo n.º 1
0
    def prepare(self):
        info = VideoInfo(self.name)

        if not self.vid:
            topicid = match1(self.url, 'topicid=([^&]+)')
            vid = match1(self.url, 'vid=([^&]+)')

            if not topicid or not vid:
                html = get_content(self.url)
                topicid = topicid or match1(html, 'topicid : \"([^\"]+)', 'topicid=([^&]+)')
                vid = vid or match1(html, 'vid : \"([^\"]+)', 'vid=([^&]+)')
        
            self.vid = (topicid, vid)

        topicid, _vid = self.vid
        code = _vid[-2:]
        video_xml = get_content('http://xml.ws.126.net/video/{}/{}/{}_{}.xml'.format(code[0], code[1], topicid, _vid))
        info.title = compact_unquote(match1(video_xml, '<title>([^<]+)'))

        for tp in self.sopported_stream_types:
            searchcode = '<{}Url><flv>([^<]+)'.format(tp)
            url = match1(video_xml, searchcode)
            if url:
                info.stream_types.append(self.stream_2_id[tp])
                info.streams[self.stream_2_id[tp]] = {'container': 'flv', 'video_profile': self.stream_2_profile[tp], 'src' : [url], 'size': 0}
        return info
Ejemplo n.º 2
0
    def prepare(self):

        info = VideoInfo(self.name)
        if self.url:
            self.vid = match1(self.url, '_(\d+)', 'm/(\d+)', 'v/(\d+)')

        add_header('Referer', 'http://m.video.baomihua.com/')
        html = get_content(
            'http://play.baomihua.com/getvideourl.aspx?flvid={}&datatype=json&devicetype=wap'
            .format(self.vid))
        data = json.loads(html)

        info.title = compact_unquote(data["title"])
        host = data['host']
        stream_name = data['stream_name']
        t = data['videofiletype']
        size = int(data['videofilesize'])

        hls = data['ishls']
        url = "http://{}/{}/{}.{}".format(host, hls, stream_name, t)
        info.stream_types.append('current')
        info.streams['current'] = {
            'video_profile': 'current',
            'container': t,
            'src': [url],
            'size': size
        }
        return info
Ejemplo n.º 3
0
def location_dec(string):
    head = int(string[0])
    string = string[1:]
    rows = head
    cols = int(len(string)/rows) + 1
    
    out = ""
    full_row = len(string) % head
    for c in range(cols):
        for r in range(rows):
            if c == (cols - 1) and r >= full_row:
                continue
            if r < full_row:
                char = string[r*cols+c]
            else:
                char = string[cols*full_row+(r-full_row)*(cols-1)+c]
            out += char
    return compact_unquote(out).replace("^", "0")
Ejemplo n.º 4
0
    def prepare(self):


        if self.url:
            self.vid = match1(self.url, '_(\d+)', 'm/(\d+)')

        add_header('Referer', 'http://m.video.baomihua.com/')
        html = get_content('http://play.baomihua.com/getvideourl.aspx?flvid={}&datatype=json&devicetype=wap'.format(self.vid))
        data = json.loads(html)
        self.title = compact_unquote(data["title"])
        host = data['host']
        stream_name = data['stream_name']
        t = data['videofiletype']
        size = int(data['videofilesize'])

        url = "http://{}/pomoho_video/{}.{}".format(host, stream_name, t)
        self.stream_types.append('current')
        self.streams['current'] = {'video_profile': 'current', 'container': t, 'src': [url], 'size' : size}
Ejemplo n.º 5
0
Archivo: video.py Proyecto: Yu1984/ykdl
    def prepare(self):

        if not self.vid:
            html = get_content(self.url)
            topiccid = match1(html, 'topicid : \"([^\"]+)', 'topicid=([^&]+)')
            vid = match1(html, 'vid : \"([^\"]+)', 'vid=([^&]+)')
            self.vid = (topiccid, vid)
        topiccid, _vid = self.vid
        code = _vid[-2:]
        video_xml = get_content('http://xml.ws.126.net/video/{}/{}/{}_{}.xml'.format(code[0], code[1], topiccid, _vid))
        self.title = compact_unquote(match1(video_xml, '<title>([^<]+)'))

        for tp in self.sopported_stream_types:
            searchcode = '<{}Url><flv>([^<]+)'.format(tp)
            url = match1(video_xml, searchcode)
            if url:
                self.stream_types.append(tp)
                self.streams[tp] = {'container': 'flv', 'video_profile': self.stream_2_profile[tp], 'src' : [url], 'size': 0}
Ejemplo n.º 6
0
    def test_compat_unquote(self):
        self.assertEqual(compact_unquote('abc%20def'), 'abc def')
        self.assertEqual(compact_unquote('%7e/abc+def'), '~/abc+def')
        self.assertEqual(compact_unquote(''), '')
        self.assertEqual(compact_unquote('%'), '%')
        self.assertEqual(compact_unquote('%%'), '%%')
        self.assertEqual(compact_unquote('%%%'), '%%%')
        self.assertEqual(compact_unquote('%2F'), '/')
        self.assertEqual(compact_unquote('%2f'), '/')
        self.assertEqual(compact_unquote('%E6%B4%A5%E6%B3%A2'), u'津波')
        self.assertEqual(
            compact_unquote('''<meta property="og:description" content="%E2%96%81%E2%96%82%E2%96%83%E2%96%84%25%E2%96%85%E2%96%86%E2%96%87%E2%96%88" />
%<a href="https://ar.wikipedia.org/wiki/%D8%AA%D8%B3%D9%88%D9%86%D8%A7%D9%85%D9%8A">%a'''),
            u'''<meta property="og:description" content="▁▂▃▄%▅▆▇█" />
%<a href="https://ar.wikipedia.org/wiki/تسونامي">%a''')
        self.assertEqual(
            compact_unquote('''%28%5E%E2%97%A3_%E2%97%A2%5E%29%E3%81%A3%EF%B8%BB%E3%83%87%E2%95%90%E4%B8%80    %E2%87%80    %E2%87%80    %E2%87%80    %E2%87%80    %E2%87%80    %E2%86%B6%I%Break%25Things%'''),
u'''(^◣_◢^)っ︻デ═一    ⇀    ⇀    ⇀    ⇀    ⇀    ↶%I%Break%Things%''')
Ejemplo n.º 7
0
 def get_url(self):
     if self.url_patterns:
         v_url = match1(self.html, *self.url_patterns)
         if v_url.startswith('http%3A'):
             v_url = compact_unquote(v_url)
         self.v_url = [v_url]
Ejemplo n.º 8
0
    def test_compat_unquote(self):
        self.assertEqual(compact_unquote('abc%20def'), 'abc def')
        self.assertEqual(compact_unquote('%7e/abc+def'), '~/abc+def')
        self.assertEqual(compact_unquote(''), '')
        self.assertEqual(compact_unquote('%'), '%')
        self.assertEqual(compact_unquote('%%'), '%%')
        self.assertEqual(compact_unquote('%%%'), '%%%')
        self.assertEqual(compact_unquote('%2F'), '/')
        self.assertEqual(compact_unquote('%2f'), '/')
        self.assertEqual(compact_unquote('%E6%B4%A5%E6%B3%A2'), u'津波')
        self.assertEqual(
            compact_unquote(
                '''<meta property="og:description" content="%E2%96%81%E2%96%82%E2%96%83%E2%96%84%25%E2%96%85%E2%96%86%E2%96%87%E2%96%88" />
%<a href="https://ar.wikipedia.org/wiki/%D8%AA%D8%B3%D9%88%D9%86%D8%A7%D9%85%D9%8A">%a'''
            ), u'''<meta property="og:description" content="▁▂▃▄%▅▆▇█" />
%<a href="https://ar.wikipedia.org/wiki/تسونامي">%a''')
        self.assertEqual(
            compact_unquote(
                '''%28%5E%E2%97%A3_%E2%97%A2%5E%29%E3%81%A3%EF%B8%BB%E3%83%87%E2%95%90%E4%B8%80    %E2%87%80    %E2%87%80    %E2%87%80    %E2%87%80    %E2%87%80    %E2%86%B6%I%Break%25Things%'''
            ),
            u'''(^◣_◢^)っ︻デ═一    ⇀    ⇀    ⇀    ⇀    ⇀    ↶%I%Break%Things%''')
Ejemplo n.º 9
0
 def get_url(self):
     url_raw = match1(html, '&videoURL=([^&]+)')
     self.v_url = [compact_unquote(url_raw)]