diff options
author | James Meyer <james.meyer@operamail.com> | 2011-12-07 19:40:39 (GMT) |
---|---|---|
committer | James Meyer <james.meyer@operamail.com> | 2011-12-07 19:40:39 (GMT) |
commit | f441710103513f9621672152b889bfda7f50f064 (patch) | |
tree | acbcec242d3444383c46162dd27d964c1eeac9e4 /abs/core/supplemental-web/contents/count.py | |
parent | f57e609997d91dbdfaa2e18b1e6e7e95876831bc (diff) | |
download | linhes_pkgbuild-f441710103513f9621672152b889bfda7f50f064.zip linhes_pkgbuild-f441710103513f9621672152b889bfda7f50f064.tar.gz linhes_pkgbuild-f441710103513f9621672152b889bfda7f50f064.tar.bz2 |
tilda, wmaker e16 settings: move /reneame to their proper place in the tree.
Diffstat (limited to 'abs/core/supplemental-web/contents/count.py')
-rw-r--r-- | abs/core/supplemental-web/contents/count.py | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/abs/core/supplemental-web/contents/count.py b/abs/core/supplemental-web/contents/count.py new file mode 100644 index 0000000..6d813c1 --- /dev/null +++ b/abs/core/supplemental-web/contents/count.py @@ -0,0 +1,89 @@ +#!/usr/bin/python +# import MySQL module + +import MySQLdb +import sys +import getopt +import socket + + +def main(argv): + grandtotal=0 + grandtotal_current=0 + db = MySQLdb.connect(host="localhost", user="mythtv", passwd="mythtv", db="mythconverg") + # create a cursor + cursor = db.cursor() + # execute SQL statement + cursor.execute("SELECT unix_timestamp(starttime),unix_timestamp(endtime),title FROM oldrecorded ORDER by starttime;") + result = cursor.fetchall() + + for row in result: + # print row[0], row[1] ,row [2] + start=row[0] + end=row[1] + if ( end > start ): + total = (end - start) /60 + grandtotal+=total + hours = grandtotal / 60.0 + days = hours / 24.0 + + cursor.execute("SELECT unix_timestamp(starttime),unix_timestamp(endtime),title FROM recorded where not (recgroup=(%s)) ORDER by starttime",("LiveTV")) + result_current = cursor.fetchall() + for row in result_current: + start=row[0] + end=row[1] + if ( end > start ): + total = (end - start) /60 + grandtotal_current+=total + hours_current = grandtotal_current / 60.0 + days_current = hours_current / 24.0 + + print '<div id="header">' + + print "<table>" + print " <tr>" + print " <td> Currently there are " , len(result_current) , " recorded programs. With a viewing time of %.2f days or %.2f hours. </td>" %(days_current,hours_current) + print " </tr>" + print "</table>" + print "</br> " + + print "<table>" + print " <tr>" + print " <td> Overall there have been " , len(result) , "shows recorded. With viewing time of %.2f days or %.2f hours </td>"%(days,hours) + print " </tr>" + print "</table>" + print '</div>' + print "</br> </br> " +#Top shows + print '<div id="content"> <p></p>' + print '<table class="sample">' + print "Top 20 Shows" + cursor.execute("select title,count(title),category as numtitle from oldrecorded group by title having (COUNT(title) > 1) order by (COUNT(title)) DESC limit 20;" ) + result = cursor.fetchall() + for row in result: + print " <tr>" + print " <td>",row[0],"</td>" + print " <td>",row[2],"</td>" + print " <td>",row[1],"</td>" + print " </tr>" + # print "%40s %26s %10s" %(row[0],row[2],row[1]) + print "</table>" + print "</div>" +#Top categorys + + print '<div id="column"></div>' + print '<table class="sample">' + print "Top 20 Categories" + cursor.execute("select category,count(category) as numtitle from oldrecorded group by category having (COUNT(category) > 1) order by (COUNT(category)) DESC limit 20; " ) + result = cursor.fetchall() + for row in result: + print " <tr>" + print " <td>",row[0],"</td>" + print " <td>",row[1],"</td>" + print " </tr>" + #print "%16s %16s" %(row[0],row[1]) + print "</table>" + print "</div>" + +if __name__ == "__main__": + main(sys.argv[1:])
\ No newline at end of file |