aboutsummaryrefslogtreecommitdiff
path: root/channelname.sh
blob: 4f98ff614a72628c51675cedd7edfcd86cf5e1b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash
# if a item on the db doesnt have a channel name. it will fetch it
i=1
max=$(( $(sqlite3 ./youtube_stuffs.db 'select rowid from ytlist order by rowid desc limit 1;') ))
while :; do
    urlid="$(sqlite3 ./youtube_stuffs.db 'select id from ytlist where rowid='$i';')"
    channelname="$(sqlite3 ./youtube_stuffs.db 'select channel from ytlist where rowid='$i';')"
    if [ -z "$channelname" ]; then
        setchannel=$(youtube-dl --get-filename -o "%(channel)s" "https://youtube.com/watch/?v=$urlid" | sed "s/'/''/g")
        sqlite3 ./youtube_stuffs.db "update ytlist set channel='$setchannel' where rowid=$i;"
        printf "$i::$urlid\n"
    fi

    ((i=$i+1))
    if (( $i >= $max + 1 )); then
        break
    fi
done