args = parser.parse_args() mysql_con = MySQLdb.connect (host = "localhost",user = "******",passwd = "xbmc",db = "MyVideos75") mc = mysql_con.cursor() if args.episode: sortedEpList = [] # (@)> - sql to get most recent episodes where playCount is not null order by lastPlayed mc.execute("select lastPlayed, strTitle, c12, c13, c00 from episodeview where playCount is not null order by lastPlayed desc limit %d" % args.num) print "Recently watched episodes:" for m in mc: # stupid hack this is a clunky POS timestamp = "%s: " % (m[0]) showname = m[1] showname = showname.ljust(args.padding) ep ="s%se%s:" % (formatNoAsStr(m[2]), formatNoAsStr(m[3])) ep = ep.ljust(args.padding/2) prstr = timestamp + showname + ep + m[4] sortedEpList.append(prstr) sortedEpList.sort() for i in sortedEpList: print i if args.movies: movieList= [] # (@)> - sql to get most recent movies mc.execute("select lastPlayed, c00 from movieview order by lastPlayed desc limit %d" % args.num) print "\nRecently Watched Movies:" for m in mc: timestamp = "%s:\t" % (m[0]) prstr = "%s: %s" % (m[0], m[1]) movieList.append(prstr)
import MySQLdb import argparse import gomXBMCTools parser = argparse.ArgumentParser(description='Prints out all episodes for a given show') parser.add_argument('-f', '--filename', action="store_true", default=False, required=False, help='print out path of episode too') parser.add_argument('-s', '--show', type=str, required=True, help='the shows name') parser.add_argument('-p', '--padding', type=int, default=60, required=False, help='column padding value') args = parser.parse_args() # globals sortedEpList = [] actual_showname = "" mysql_con = MySQLdb.connect (host = "localhost",user = "******",passwd = "xbmc",db = "MyVideos75") mc = mysql_con.cursor() mc.execute("select strTitle, c12, c13, c00, strPath, strFilename from episodeview where strTitle like '%" + args.show + "%'" ) for m in mc: actual_showname = m[0] s = "s%se%s:\t\t" % (gomXBMCTools.formatNoAsStr( m[1]), gomXBMCTools.formatNoAsStr(m[2])) ept = str(m[3]).ljust(args.padding) s+= ept if args.filename: s += "%s%s" % (m[4], m[5]) sortedEpList.append(s) print "Episodes in XBMC Library for: %s" % actual_showname sortedEpList.sort() for s in sortedEpList: print s