Download TS files from video stream

前端 未结 14 1623
遥遥无期
遥遥无期 2020-12-22 17:55

Videos on most sites make use of progressive downloading, which means that the video is downloaded to my computer, and easy to trace. There are lots of extensions out there

14条回答
  •  误落风尘
    2020-12-22 18:29

    using this post

    • Open Firefox / chrome

    • open page the video

    • Play Video

    • click F12 on keyboard -> network

    • in Filter URLs ts

    • copy link of ts

    • remove index and ts extension from link

      for example:

      http://vid.com/vod/mp4:vod/PRV/Yg0WGN_6.mp4/media_b180000_454.ts
      

      will be copied as

       http://vid.com/vod/mp4:vod/PRV/Yg0WGN_6.mp4/media_b180000
      

    insert in below script under LINK

    #!/bin/bash
    
    # insert here urls
    LINK=(
    
    'http://vid.com/vod/mp4:vod/PRV/Yg0WGN_6.mp4/media_b180000' # replace this with your url 
    
    )
    
    mkdir my-videos
    cd mkdir my-videos
    
    CNT=0
    
    for URL in ${LINK[@]}
    do
      # create folder for streaming media
      CNT=$((CNT + 1))
      mkdir $CNT
      cd $CNT
    
      (
    
       DIR="${URL##*/}"
    
       # download all videos
       wget $URL'_'{0..1200}.ts
    
       # link videos
       echo $DIR'_'{0..1200}.ts | tr " " "\n" > tslist
       while read line; do cat $line >> $CNT.mp4; done < tslist
    
       rm -rf media* tslist
       ) &
       cd ..
    
    done
    
    wait
    

    EDIT

    adding script in python - runs on windows and linux

    import urllib.request
    import os
    import shutil
    
    my_lessons = [
       #  http://vid.com/vod/mp4:vod/PRV/Yg0WGN_6.mp4/media_b180000_454.ts
        "http://vid.com/vod/mp4:vod/PRV/Yg0WGN_6.mp4/media_b180000" # replace this with your url 
    
    
    ]
    
    lesson_dir = "my_vids"
    try:
        shutil.rmtree(lesson_dir)
    except:
        print "ok"
    
    os.makedirs(lesson_dir)
    os.chdir(lesson_dir)
    
    for lesson, dwn_link in enumerate(my_lessons):
        print ("downloading lesson  %d.. " % (lesson), dwn_link)
        file_name = '%04d.mp4' % lesson
        f = open(file_name, 'ab')
        for x in range(0, 1200):
            try:
                rsp = urllib.request.urlopen(dwn_link + "_%04d.ts" % (x) )
            except:
                break
            file_name = '%d.mp4' % lesson
            print "downloading  %d.ts" % (x)
            f.write(rsp.read())
        f.close()
    
    
    
    print "done good luck!! ==================  "
    

    if the script fails, or downloads empty file, try removing the try wrap to see what fails

提交回复
热议问题