Jump to content

Script To Download Rename Youtube Videos.


Jamo
 Share

Recommended Posts

Hi

I have 20 links to youtube, and I should download those files and convert them to mp3. I can use youtube-dl or just "watch" those videos and then copy them from tmp folder. Then I have 20 flv files and I should look each of those name, and so on. Then finally use ffmpeg to convert those to mp3.

So I would like to create a script to download each video, check its name, rename it and finally ffmpg those to mp3.

Im not that good with bash scripting, so Im asking someone could help me to create that script. It would be nice, if that script could read files from list.

At least it would be nice if that script could download and rename those files. FFmpeg could be used manually.

Thanks for your help.

Here is what Iv done:

#!/bin/bash
echo "type url"

read url

wget -O file "$url"

videoname=`cat file | grep "meta property" |grep title | grep "content"`
echo "$videoname"
#then this script should rename that video, it has downloaded

So as test video I used just one of hka5 episodes from youtube.

Then filename has still one problem:

 
.
.
Saving to: `file'

    [  <=>                                                  ] 143,142      479K/s   in 0.3s    

2010-11-05 17:03:25 (479 KB/s) - `file' saved [143142]

    <meta property="og:title" content="DEFCON 18 - Hak5" />

so it should cut parts in "" so filename should be DEFCON 18 -Hak5

Edited by Jarmo
Link to comment
Share on other sites

so Iv done some research and this is what I got:

echo "type url"

#read url
url=http://www.youtube.com/watch?v=PMj2zj-45ik ##just cause I dont want paste url each time I try
#wget -O file "$url" ## same as above

echo "Downloading youtube video"
videoname=`cat file | grep "meta property" |grep title | grep "content" | cut -c40-100 | sed 's/\(.*\)./\1/' | sed 's/\(.*\)./\1/' | sed 's/\(.*\)./\1/' | sed 's/\(.*\)./\1/'`

echo "$videoname"

This works, but then I took closer look to youtube-dl help and it can also get title automaticly to filename, so my script is needless.

so when i download youtube videos

youtube-dl -t http://www.youtube.com/watch?v=PMj2zj-45ik
[youtube] Setting language
[youtube] PMj2zj-45ik: Downloading video webpage
[youtube] PMj2zj-45ik: Downloading video info webpage
[youtube] PMj2zj-45ik: Extracting video information
[download] Destination: DEFCON_18_Hak5-PMj2zj-45ik.mp4
[download]   0.2% of 715.24M at  565.93k/s ETA 21:31^C

it still leaves some characters to filename, but this is good enough.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...