Download TS files from video stream

前端 未结 14 1597
遥遥无期
遥遥无期 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:23

    I made some changes to dina's answer to avoid attempting to download/combine 1200 parts if there aren't that many.

    I also found it helpful to sort by waterfall in the network tab of chrome. This will sort by the time the files are downloaded, so when you are streaming a video the most recently downloaded parts will be at the top, making it easy to find the .ts links.

    #!/bin/bash
    
    # Name of the containing folder
    GROUP="My Videos"
    
    # Example link: https://vids.net/ABCAED/AADDCDE/m3u8/AADDCDE/AADDCDE_0.ts
    # Insert below as: https://vids.net/ABCAED/AADDCDE/m3u8/AADDCDE/AADDCDE
    
    # INSERT LINKS TO VIDEOS HERE
    LINK=(
    'Title for the video link'
    'https://vids.net/ABCAED/AADDCDE/m3u8/AADDCDE/AADDCDE'
    'Title for the next video'
    'https://vids.net/EECEADFE/EECEADFE/m3u8/EECEADFE/EECEADFE'
    )
    
    # ------------------------------------------------------------------------------
    mkdir "$GROUP"
    cd "$GROUP"
    
    I=0
    while [ $I -lt ${#LINK[@]} ]
    do
      # create folder for streaming media
      TITLE=${LINK[$I]}
      mkdir "$TITLE"
      cd "$TITLE"
      mkdir 'parts'
      cd 'parts'
    
      J=$((I + 1))
      URL=${LINK[$J]}
    
      I=$((I + 2))
    
      DIR="${URL##*/}"
    
      # download all streaming media parts
      VID=-1
      while [ $? -eq 0 ];
      do
        VID=$((VID + 1))
        wget $URL'_'$VID.ts
      done
    
      # combine parts
      COUNTER=0
      while [  $COUNTER -lt $VID ]; do
        echo $DIR'_'$COUNTER.ts | tr " " "\n" >> tslist
        let COUNTER=COUNTER+1
      done
      while read line; do cat $line >> $TITLE.ts; done < tslist
    
      rm -rf tslist
      mv "$TITLE.ts" "../$TITLE.ts"
    
      cd ..
      rm -rf 'parts'
      cd ..
    
    done
    

提交回复
热议问题