Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter takerukobayashi

    (@takerukobayashi)

    What I wrote in the code area in the article is:

    #!/bin/bash
    # this shellscript requires a YouTube video URL as an argument
    
    # prefix and suffix of thumbnail URL
    prefix="https://img.youtube.com/vi/"
    suffix="/maxresdefault.jpg"
    vidprefix="https://www.youtube.com/watch?v="
    
    # make thumbnail URL for argument YouTube video
    #id=$(cut -d'=' -f 2 <<<$1)
    id=<code>echo ${1} | rev | cut -c 1-11 | rev</code>
    url=$prefix$id$suffix
    
    # download thumnail image
    curl -o ~/Downloads/image.jpg $url
    
    # get video number
    vidurl=$vidprefix$id
    title=<code>curl $vidurl 2>&1 | grep -oP &quot;(?<=<title>)(.+)(?=</title>)&quot;</code>
    number=<code>echo $title | grep -oP &quot;(?<=Part )(.+)(?= -)&quot;</code>
    
    # edit SVG image
    sed -i -e "s:>No. \?[0-9][0-9]\?[0-9]\?:>No. ${number}:g" ~/.np/svg.svg
    inkscape -e ~/.np/png.png ~/.np/svg.svg
    convert ~/Downloads/image.jpg ~/.np/png.png -composite ~/Downloads/${number}.jpg
    rm ~/Downloads/image.jpg ~/.np/png.png
    #mv *.jpg ~/Downloads/
    
    exit 0
Viewing 1 replies (of 1 total)