Ticket #1746: createdb.sh

File createdb.sh, 2.4 KB (added by numbars@…, 16 years ago)

script to create test videometadata to demonstrate problems with mythvideo 0.19

Line 
1#!/bin/bash
2# /usr/local/bin/createdb.sh
3
4# WARNING THIS WILL WIPE YOUR CURRENT videometadata info - SO BACKUP FIRST IF REQ'D OR remove it
5mysql -u root -e "DROP TABLE IF EXISTS mythconverg.videometadata;"
6mysql -u root -e "CREATE TABLE mythconverg.videometadata (
7  intid int(10) unsigned NOT NULL auto_increment,
8  title varchar(128) NOT NULL default '',
9  director varchar(128) NOT NULL default '',
10  plot text,
11  rating varchar(128) NOT NULL default '',
12  inetref varchar(32) NOT NULL default '',
13  year int(10) unsigned NOT NULL default '0',
14  userrating float NOT NULL default '0',
15  length int(10) unsigned NOT NULL default '0',
16  showlevel int(10) unsigned NOT NULL default '0',
17  filename text NOT NULL,
18  coverfile text NOT NULL,
19  childid int(11) NOT NULL default '-1',
20  browse tinyint(1) NOT NULL default '1',
21  playcommand varchar(255) default NULL,
22  category int(10) unsigned NOT NULL default '0',
23  PRIMARY KEY  (intid),
24  KEY director (director),
25  KEY title (title),
26  KEY title_2 (title)
27) TYPE=MyISAM;"
28
29
30# INSERT DUMMY RECORDS
31for i in `seq 1 8`;
32do
33        for j in `seq 1 8`;
34        do
35                for k in `seq 1 8`;
36                do
37                        for l in `seq 1 20`;
38                        do
39                           echo $i,$j,$k,$l
40                           mysql -u root -e "INSERT INTO mythconverg.videometadata VALUES (-1,'Video File ${i}${j}${k}${l}','David Fincher','An office employee and a soap salesman build a global organization to help vent male aggression.','NR','0137523',1999,8.6,139,1,'/myth/video/library/folder00${i}/folder10${j}/folder20${k}/video file ${i}${j}${k}${l}.avi','/myth/video/.covers/0137523.jpg',-1,1,'playvideo.sh \"/cdrom/video file ${i}${j}${k}${l}.avi\" 0${i}${j}${k}', ${i});"
41                        done
42                done   
43        done
44done   
45
46exit $EXITVAL
47
48# CREATE DUMMY FILES (If required. Not needed in 0.18)
49# My setup used the number at the end of the playcommand to request the user insert that disk number where the files would be found
50VIDEO_ID=0
51EXITVAL=0
52while [ ${EXITVAL} -eq 0 ] ; do ### endless loop for if $1 = -1
53        VIDEO_ID=$(mysql -u root -e "SELECT intid FROM mythconverg.videometadata WHERE intid > ${VIDEO_ID} && browse = 1 LIMIT 0, 1;" -BN)
54        if [[ ${VIDEO_ID} == "" ]] ; then
55                EXITVAL=1
56        else
57                VIDFILE=$(mysql -u root -e "SELECT filename FROM mythconverg.videometadata WHERE intid = $VIDEO_ID;" -BN)
58                VIDPATH=${VIDFILE%/*}
59               
60                if [ ! -e "${VIDPATH}" ] ; then
61                    mkdir -p "${VIDPATH}"
62                    echo "Created folder ${VIDPATH}"
63                fi
64               
65                if [ ! -e "${VIDFILE}" ] ; then
66          touch "${VIDFILE}"
67                    echo "Created file ${VIDFILE}"
68                fi
69        fi
70done
71
72