blob: b3f91ece86b0b202915ed098f9ab4b4439c3670e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#!/bin/bash
# variables
database=watchedlist.db
# checks
if [ ! -f $database ]
then
echo Database $database file missing, exiting
exit 0
fi
# blank database check
# movies
if [ -f "movies.csv" ]; then rm movies.csv; fi
sqlite3 -noheader -csv $database "select title from movie_watched;" > movies.csv
sed -i -e 's|\"||g' -e 's|^|* |g' movies.csv
sort -k 2 < movies.csv > movies.md
rm movies.csv
# tv shows
sqlite3 -noheader -csv $database "select * from tvshows;" > tv_shows_index.csv
watched_id=$(sqlite3 -noheader $database "select idShow from episode_watched;" | uniq)
for i in $watched_id; do grep "$i" tv_shows_index.csv | cut -f2- -d, >> tv_shows.csv; done
sed -i -e 's|\"||g' -e 's|^|* |g' tv_shows.csv
sort -k 2 < tv_shows.csv > tv_shows.md
rm tv_shows.csv tv_shows_index.csv
|