zoukankan      html  css  js  c++  java
  • 合并百度影音的离线数据 with python 2.1 bdv格式的更新

    最近百度影音的离线下载文件,格式有新变化。

    经过分析,是bdv格式又有新格式,从最初的bdv0001,到bdv.config 的file。。。。,这次更新的格式是直接包含一个片段,其中还有使用guid绑定索引和文件名。

    新版本以“#EXTM3U”作为标识,并且输出格式是mpeg2(通过GSpot检查的)。

    以下是新的moviefmt.py脚本,主程序还是复用2.0的mergefilm.py

    # -*- coding: UTF-8 -*-
    
    import os
    import io
    import sys
    import string
    import shutil
    import codecs
    
    
    def read_bdv_index_V1(objFile):
        piece_list= list()  
        for line in objFile:
            if(line[0:4] != 'file'):
                continue;
            strings = string.split(line,'/')
            tarfile = strings[len(strings)-1]        
            tempText = string.strip(tarfile)
            piece_list.append(tempText)
        return "avi",piece_list
    
    
    def read_bdv_index_V2(objFile):
        piece_list= list()  
        for line in objFile:       
            nPos = line.count('bdv')
            if( nPos <=0):
                continue;      
            tarfile = line[0:len(line)-2]     
            piece_list.append(tarfile)    
        return "mpeg",piece_list
    
    
    def read_bdv_index(filename): 
        piece_list= list()   
        ext_type = None
        objFile = codecs.open(filename,'r','utf-8')    
        topline = objFile.readline();
        bdv_ver = topline.replace("
    ","")
        if(bdv_ver == '#EXTM3U'):
            ext_type,piece_list = read_bdv_index_V2(objFile)
        else:
            ext_type,piece_list  = read_bdv_index_V1(objFile)
    
        objFile.close()       
        return  (ext_type ,piece_list)        
    
    
       
    
    def read_bdv_file(filename):
        piece_list= list()
        piece_list.append('*.bdv_*')
        return  ('avi',piece_list)
    
    def read_rmvb_file(filename):
        piece_list= list()
        piece_list.append('*.rmvb_*')
        return  ('rmvb',piece_list)
    
    def read_mkv_file(filename):
        piece_list= list()    
        piece_list.append('*.mkv_*')
        return  ('mkv',piece_list)
    
    def read_mp4_file(filename):
        piece_list= list()    
        piece_list.append('*.mp4_*')
        return  ('mp4',piece_list)
    
    def read_mkv_2_file(filename):
        piece_list= list()    
        piece_list.append('video_*')
        return  ('mkv',piece_list)
  • 相关阅读:
    loaded some nib but the view outlet was not set
    指标评比
    IOS DEVELOP FOR DUMMIES
    软件测试题二
    javascript select
    DOM节点类型详解
    mysql操作
    UVA 10055
    solutions for 'No Suitable Driver Found For Jdbc'
    解决git中文乱码问题
  • 原文地址:https://www.cnblogs.com/febwave/p/3441000.html
Copyright © 2011-2022 走看看