linux - Shell file parsing to automate youtube uploads -
i writing small script mass upload videos youtube.. looks this:
#! /bin/sh python --version file in ./*.mp4 ; export title=$(basename "$file" ".mp4") echo $title "for" $file youtube-upload -m mail@mailer.com -p pass -c category -t "$title" -d "description" "$file" done
where youtube-upload cli based python uploader..
my question can see i'm taking title file name path, , description same :(. want write description text or xml file parse it, , upload proper description each file..
how using shell commands in context?
thanks suggestions
have 1 file containing of filename->description mappings:
my file.mp4 description file2.mp4 description last file.mp4 description ilied.mp4 description
and grab line beginning filename , use rest of line:
#! /bin/sh python --version file in ./*.mp4 ; export title=$(basename "$file" ".mp4") echo $title "for" $file youtube-upload -m mail@mailer.com -p pass -c category -t "$title" -d "$(grep "^$(basename "$file")" desc | sed 's/.*.mp4 //')" "$file" done
looking @ what's in $(...)
:
grep "^$(basename "$file")" desc | sed 's/.*.mp4 //'
the grep
finds line starts basename($file) in "desc" file , uses sed
rid of filename, leaving rest of line (which description).
note doesn't need part of youtube-upload
comand line. can toss variable:
#! /bin/sh python --version file in ./*.mp4 ; export title=$(basename "$file" ".mp4") echo $title "for" $file description=$(grep "^$(basename "$file")" desc | sed 's/.*.mp4 //') youtube-upload -m mail@mailer.com -p pass -c category -t "$title" -d "$description" "$file" done
Comments
Post a Comment