예제 #1
0
파일: le.py 프로젝트: ytwangli/ykdl
    def prepare(self):
        info = VideoInfo(self.name)
        stream_temp = {'1080p': None , '1300': None, '1000':None , '720p': None, '350': None }
        self.__STREAM_TEMP__.append(stream_temp)
        if not self.vid:
            self.vid = match1(self.url, r'http://www.le.com/ptv/vplay/(\d+).html', '#record/(\d+)')

        #normal process
        info_url = 'http://api.le.com/mms/out/video/playJson?id={}&platid=1&splatid=101&format=1&tkey={}&domain=www.le.com'.format(self.vid, calcTimeKey(int(time.time())))
        r = get_content(info_url)
        data=json.loads(r)

        info.title = data['playurl']['title']
        available_stream_id = sorted(list(data["playurl"]["dispatch"].keys()), key = self.supported_stream_types.index)
        for stream in available_stream_id:
            s_url =data["playurl"]["domain"][0]+data["playurl"]["dispatch"][stream][0]
            s_url+="&ctv=pc&m3v=1&termid=1&format=1&hwtype=un&ostype=Linux&tag=le&sign=le&expect=3&tn={}&pay=0&iscpn=f9051&rateid={}".format(random.random(),stream)
            r2=get_content(s_url)
            data2=json.loads(r2)

            # hold on ! more things to do
            # to decode m3u8 (encoded)
            m3u8 = get_content(data2["location"], charset = 'ignore')
            m3u8_list = decode(m3u8)
            stream_id = self.stream_2_id[stream]
            info.streams[stream_id] = {'container': 'm3u8', 'video_profile': self.stream_2_profile[stream], 'size' : 0}
            stream_temp[stream] = compact_tempfile(mode='w+t', suffix='.m3u8')
            stream_temp[stream].write(m3u8_list)
            info.streams[stream_id]['src'] = [stream_temp[stream].name]
            stream_temp[stream].flush()
            info.stream_types.append(stream_id)
        return info
예제 #2
0
파일: wrap.py 프로젝트: zhangn1985/ykdl
def launch_ffmpeg(basename, ext, lenth):
    if ext in ['ts', 'mpg', 'mpeg']:
        inputfile = []
        for i in range(lenth):
            inputfile.append('%s_%d_.%s' % (basename, i, ext))
        inputfile = 'concat:%s' % '|'.join(inputfile)

        if ext == 'ts':
            ext = 'mp4'
        outputfile = basename + '.' + ext

        cmd = ['ffmpeg', '-y', '-i', inputfile, '-c', 'copy', '-hide_banner']
    else:
        #build input
        inputfile = compact_tempfile(mode='w+t', suffix='.txt', dir='.', encoding='utf-8')
        for i in range(lenth):
            inputfile.write('file \'%s_%d_.%s\'\n' % (basename, i, ext))
        inputfile.flush()

        outputfile = basename + '.' + ext

        cmd = ['ffmpeg', '-safe', '-1', '-y', '-f', 'concat', '-i', inputfile.name, '-c', 'copy', '-hide_banner']
        if ext == 'mp4':
            cmd += ['-bsf:a', 'aac_adtstoasc']

    cmd.append(outputfile)
    print('Merging video %s using ffmpeg:' % basename)
    subprocess.call(cmd)

    if os.name == 'nt':
        try:
            inputfile.close()
            os.remove(inputfile.name)
        except:
            pass
예제 #3
0
파일: le.py 프로젝트: togitss/ykdl
    def prepare(self):
        info = VideoInfo(self.name)
        stream_temp = {
            '1080p': None,
            '1300': None,
            '1000': None,
            '720p': None,
            '350': None
        }
        self.__STREAM_TEMP__.append(stream_temp)
        if not self.vid:
            self.vid = match1(self.url, 'vplay/(\d+).html', '#record/(\d+)')

        #normal process
        url = 'http://player-pc.le.com/mms/out/video/playJson?id={}&platid=1&splatid=101&format=1&tkey={}&domain=www.le.com&region=cn&source=1000&accesyx=1'.format(
            self.vid, calcTimeKey(int(time.time())))
        r = get_content(url)
        data = json.loads(r)
        data = data['msgs']

        info.title = data['playurl']['title']
        available_stream_id = sorted(list(data["playurl"]["dispatch"].keys()),
                                     key=self.supported_stream_types.index)
        for stream in available_stream_id:
            s_url = data["playurl"]["domain"][0] + data["playurl"]["dispatch"][
                stream][0]
            uuid = hashlib.sha1(s_url.encode('utf8')).hexdigest() + '_0'
            s_url = s_url.replace('tss=0', 'tss=ios')
            s_url += "&m3v=1&termid=1&format=1&hwtype=un&ostype=MacOS10.12.4&p1=1&p2=10&p3=-&expect=3&tn={}&vid={}&uuid={}&sign=letv".format(
                random.random(), self.vid, uuid)
            r2 = get_content(s_url)
            data2 = json.loads(r2)

            # hold on ! more things to do
            # to decode m3u8 (encoded)
            suffix = '&r=' + str(int(time.time() * 1000)) + '&appid=500'
            m3u8 = get_content(data2["location"] + suffix, charset='ignore')
            m3u8_list = decode(m3u8)
            stream_id = self.stream_2_id[stream]
            info.streams[stream_id] = {
                'container': 'm3u8',
                'video_profile': self.stream_2_profile[stream],
                'size': 0
            }
            stream_temp[stream] = compact_tempfile(mode='w+t', suffix='.m3u8')
            stream_temp[stream].write(m3u8_list)
            info.streams[stream_id]['src'] = [stream_temp[stream].name]
            stream_temp[stream].flush()
            info.stream_types.append(stream_id)
        return info
예제 #4
0
파일: wrap.py 프로젝트: wwqgtxx/ykdl
def launch_ffmpeg(basename, ext, lenth):
    #build input
    inputfile = compact_tempfile(mode='w+t', suffix='.txt', dir='.', encoding='utf-8')
    for i in range(lenth):
        inputfile.write('file \'%s_%d_.%s\'\n' % (basename, i, ext))
    inputfile.flush()

    outputfile = basename+ '.' + ext

    cmd = ['ffmpeg','-f', 'concat', '-safe', '-1', '-y', '-i', inputfile.name, '-c', 'copy', '-hide_banner']
    if ext == 'mp4':
        cmd += ['-absf', 'aac_adtstoasc']

    cmd.append(outputfile)
    print('Merging video %s using ffmpeg:' % basename)
    subprocess.call(cmd)
예제 #5
0
def launch_ffmpeg(basename, ext, lenth):
    #build input
    inputfile = compact_tempfile(mode='w+t', suffix='.txt', dir='.', encoding='utf-8')
    for i in range(lenth):
        inputfile.write('file \'%s_%d_.%s\'\n' % (basename, i, ext))
    inputfile.flush()

    outputfile = basename+ '.' + ext

    cmd = ['ffmpeg','-f', 'concat', '-safe', '-1', '-y', '-i', inputfile.name, '-c', 'copy', '-hide_banner']
    if ext == 'mp4':
        cmd += ['-absf', 'aac_adtstoasc']

    cmd.append(outputfile)
    print('Merging video %s using ffmpeg:' % basename)
    subprocess.call(cmd)
예제 #6
0
파일: wrap.py 프로젝트: netlovehf/ykdl
def launch_ffmpeg(basename, ext, lenth):
    print('Merging video %s using FFmpeg:' % basename)
    if ext == 'ts':
        outputfile = basename + '.mp4'
    else:
        outputfile = basename + '.' + ext

    if ext in ['ts', 'mpg', 'mpeg']:
        cmd = [
            'ffmpeg', '-y', '-hide_banner', '-i', '-', '-c', 'copy', outputfile
        ]
        pipe_input = subprocess.Popen(cmd, stdin=subprocess.PIPE).stdin

        # use pipe pass data does not need to wait subprocess
        bufsize = 1024 * 64
        for i in range(lenth):
            inputfile = '%s_%d.%s' % (basename, i, ext)
            with open(inputfile, 'rb') as fp:
                data = fp.read(bufsize)
                while data:
                    pipe_input.write(data)
                    data = fp.read(bufsize)
    else:
        # build input file
        inputfile = compact_tempfile(mode='w+t',
                                     suffix='.txt',
                                     dir='.',
                                     encoding='utf-8')
        for i in range(lenth):
            inputfile.write("file '%s_%d.%s'\n" % (basename, i, ext))
        inputfile.flush()

        cmd = [
            'ffmpeg', '-y', '-hide_banner', '-safe', '-1', '-f', 'concat',
            '-i', inputfile.name, '-c', 'copy', outputfile
        ]
        if ext == 'mp4':
            cmd[-1:-1] = ['-bsf:a', 'aac_adtstoasc']
        subprocess.call(cmd)

        if os.name == 'nt':
            try:
                inputfile.close()
                os.remove(inputfile.name)
            except:
                pass
예제 #7
0
파일: wrap.py 프로젝트: starwork/ykdl
def launch_ffmpeg(basename, ext, lenth):
    if ext in ['ts', 'mpg', 'mpeg']:
        inputfile = []
        for i in range(lenth):
            inputfile.append('%s_%d_.%s' % (basename, i, ext))
        inputfile = 'concat:%s' % '|'.join(inputfile)

        if ext == 'ts':
            ext = 'mp4'
        outputfile = basename + '.' + ext

        cmd = ['ffmpeg', '-y', '-i', inputfile, '-c', 'copy', '-hide_banner']
    else:
        #build input
        inputfile = compact_tempfile(mode='w+t',
                                     suffix='.txt',
                                     dir='.',
                                     encoding='utf-8')
        for i in range(lenth):
            inputfile.write('file \'%s_%d_.%s\'\n' % (basename, i, ext))
        inputfile.flush()

        outputfile = basename + '.' + ext

        cmd = [
            'ffmpeg', '-safe', '-1', '-y', '-f', 'concat', '-i',
            inputfile.name, '-c', 'copy', '-hide_banner'
        ]
        if ext == 'mp4':
            cmd += ['-bsf:a', 'aac_adtstoasc']

    cmd.append(outputfile)
    print('Merging video %s using ffmpeg:' % basename)
    subprocess.call(cmd)

    if os.name == 'nt':
        try:
            inputfile.close()
            os.remove(inputfile.name)
        except:
            pass
예제 #8
0
파일: le.py 프로젝트: flfq/ykdl
    def prepare(self):
        info = VideoInfo(self.name)
        stream_temp = {'1080p': None , '1300': None, '1000':None , '720p': None, '350': None }
        self.__STREAM_TEMP__.append(stream_temp)
        if not self.vid:
            self.vid = match1(self.url, 'vplay/(\d+).html', '#record/(\d+)')

        #normal process
        url = 'http://player-pc.le.com/mms/out/video/playJson?id={}&platid=1&splatid=101&format=1&tkey={}&domain=www.le.com&region=cn&source=1000&accesyx=1'.format(self.vid,calcTimeKey(int(time.time())))
        r = get_content(url)
        data=json.loads(r)
        data = data['msgs']

        info.title = data['playurl']['title']
        available_stream_id = sorted(list(data["playurl"]["dispatch"].keys()), key = self.supported_stream_types.index)
        for stream in available_stream_id:
            s_url =data["playurl"]["domain"][0]+data["playurl"]["dispatch"][stream][0]
            uuid = hashlib.sha1(s_url.encode('utf8')).hexdigest() + '_0'
            s_url = s_url.replace('tss=0', 'tss=ios')
            s_url+="&m3v=1&termid=1&format=1&hwtype=un&ostype=MacOS10.12.4&p1=1&p2=10&p3=-&expect=3&tn={}&vid={}&uuid={}&sign=letv".format(random.random(), self.vid, uuid)
            r2=get_content(s_url)
            data2=json.loads(r2)

            # hold on ! more things to do
            # to decode m3u8 (encoded)
            suffix = '&r=' + str(int(time.time() * 1000)) + '&appid=500'
            m3u8 = get_content(data2["location"]+suffix, charset = 'ignore')
            m3u8_list = decode(m3u8)
            stream_id = self.stream_2_id[stream]
            info.streams[stream_id] = {'container': 'm3u8', 'video_profile': self.stream_2_profile[stream], 'size' : 0}
            stream_temp[stream] = compact_tempfile(mode='w+t', suffix='.m3u8')
            stream_temp[stream].write(m3u8_list)
            info.streams[stream_id]['src'] = [stream_temp[stream].name]
            stream_temp[stream].flush()
            info.stream_types.append(stream_id)
        return info