@@ -656,6 +656,7 @@ def searchRecorded(self, init=False, key=None, value=None):
656656 init .Join (table = 'people' ,
657657 tableto = 'recordedcredits' ,
658658 fields = ('person' ,)))
659+ return None
659660
660661 # local table matches
661662 if key in ('title' ,'subtitle' ,'chanid' ,
@@ -667,26 +668,26 @@ def searchRecorded(self, init=False, key=None, value=None):
667668
668669 # time matches
669670 if key in ('starttime' ,'endtime' ,'progstart' ,'progend' ):
670- return ('recorded.%s=%%s ' % key , datetime .duck (value ), 0 )
671+ return ('recorded.%s=? ' % key , datetime .duck (value ), 0 )
671672
672673 if key == 'olderthan' :
673- return ('recorded.starttime<%s ' , datetime .duck (value ), 0 )
674+ return ('recorded.starttime<? ' , datetime .duck (value ), 0 )
674675 if key == 'newerthan' :
675- return ('recorded.starttime>%s ' , datetime .duck (value ), 0 )
676+ return ('recorded.starttime>? ' , datetime .duck (value ), 0 )
676677
677678 # recordedprogram matches
678679 if key in ('category_type' ,'airdate' ,'stereo' ,'subtitled' ,'hdtv' ,
679680 'closecaptioned' ,'partnumber' ,'parttotal' ,'seriesid' ,
680681 'showtype' ,'syndicatedepisodenumber' ,'programid' ,
681682 'manualid' ,'generic' ):
682- return ('recordedprogram.%s=%%s ' % key , value , 1 )
683+ return ('recordedprogram.%s=? ' % key , value , 1 )
683684
684685 if key == 'cast' :
685686 return ('people.name' , 'recordedcredits' , 4 , 1 )
686687
687688 if key == 'livetv' :
688689 if (value is None ) or (value == False ):
689- return ('recorded.recgroup!=%s ' , 'LiveTV' , 0 )
690+ return ('recorded.recgroup!=? ' , 'LiveTV' , 0 )
690691 return ()
691692
692693 return None
@@ -705,15 +706,16 @@ def searchOldRecorded(self, init=False, key=None, value=None):
705706 if init :
706707 init .table = 'oldrecorded'
707708 init .handler = OldRecorded
709+ return None
708710
709711 if key in ('title' ,'subtitle' ,'chanid' ,
710712 'category' ,'seriesid' ,'programid' ,'station' ,
711713 'duplicate' ,'generic' ,'recstatus' ,'inetref' ,
712714 'season' ,'episode' ):
713- return ('oldrecorded.%s=%%s ' % key , value , 0 )
715+ return ('oldrecorded.%s=? ' % key , value , 0 )
714716 # time matches
715717 if key in ('starttime' ,'endtime' ):
716- return ('oldrecorded.%s=%%s ' % key , datetime .duck (value ), 0 )
718+ return ('oldrecorded.%s=? ' % key , datetime .duck (value ), 0 )
717719 return None
718720
719721 @databaseSearch
@@ -734,15 +736,16 @@ def searchArtwork(self, init=False, key=None, value=None):
734736 tableto = 'recordedartwork' ,
735737 fieldsfrom = ('inetref' ,'season' ,'hostname' ),
736738 fieldsto = ('inetref' ,'season' ,'host' )),)
739+ return None
737740
738741 if key in ('inetref' , 'season' , 'host' ):
739- return ('recordedartwork.%s=%%s ' % key , value , 0 )
742+ return ('recordedartwork.%s=? ' % key , value , 0 )
740743
741744 if key in ('chanid' , 'title' , 'subtitle' ):
742- return ('recorded.%s=%%s ' % key , value , 1 )
745+ return ('recorded.%s=? ' % key , value , 1 )
743746
744747 if key == 'starttime' :
745- return ('recorded.%s=%%s ' % key , datetime .duck (value ), 1 )
748+ return ('recorded.%s=? ' % key , datetime .duck (value ), 1 )
746749
747750 return None
748751
@@ -761,20 +764,21 @@ def searchJobs(self, init=False, key=None, value=None):
761764 init .joins = (init .Join (table = 'recorded' ,
762765 tableto = 'jobqueue' ,
763766 fields = ('chanid' ,'starttime' )),)
767+ return None
764768
765769 if key in ('chanid' ,'type' ,'status' ,'hostname' ):
766- return ('jobqueue.%s=%%s ' % key , value , 0 )
770+ return ('jobqueue.%s=? ' % key , value , 0 )
767771 if key in ('title' ,'subtitle' ):
768- return ('recorded.%s=%%s ' % key , value , 1 )
772+ return ('recorded.%s=? ' % key , value , 1 )
769773 if key == 'flags' :
770- return ('jobqueue.flags&%s ' , value , 0 )
774+ return ('jobqueue.flags&? ' , value , 0 )
771775
772776 if key == 'starttime' :
773- return ('jobqueue.starttime=%s ' , datetime .duck (value ), 0 )
777+ return ('jobqueue.starttime=? ' , datetime .duck (value ), 0 )
774778 if key == 'olderthan' :
775- return ('jobqueue.inserttime>%s ' , datetime .duck (value ), 0 )
779+ return ('jobqueue.inserttime>? ' , datetime .duck (value ), 0 )
776780 if key == 'newerthan' :
777- return ('jobqueue.inserttime<%s ' , datetime .duck (value ), 0 )
781+ return ('jobqueue.inserttime<? ' , datetime .duck (value ), 0 )
778782 return None
779783
780784 @databaseSearch
@@ -789,7 +793,12 @@ def searchGuide(self, init=False, key=None, value=None):
789793 partnumber, parttotal, seriesid, originalairdate,
790794 showtype, programid, generic, syndicatedepisodenumber,
791795 ondate, cast, startbefore,startafter
792- endbefore, endafter
796+ endbefore, endafter, dayofweek, weekday
797+ first, last, callsign, commfree
798+ channelgroup, videosource,
799+ genre, rating, cast, fuzzytitle
800+ fuzzysubtitle, fuzzydescription,
801+ fuzzyprogramid, beforedate, afterdate,
793802 """
794803 if init :
795804 init .table = 'program'
@@ -799,28 +808,81 @@ def searchGuide(self, init=False, key=None, value=None):
799808 fields = ('chanid' ,'starttime' )),
800809 init .Join (table = 'people' ,
801810 tableto = 'credits' ,
802- fields = ('person' ,)))
811+ fields = ('person' ,)),
812+ init .Join (table = 'channel' ,
813+ tableto = 'program' ,
814+ fields = ('chanid' ,)),
815+ init .Join (table = 'channelgroup' ,
816+ tableto = 'program' ,
817+ fields = ('chanid' ,)),
818+ init .Join (table = 'channelgroupnames' ,
819+ tableto = 'channelgroup' ,
820+ fields = ('grpid' ,)),
821+ init .Join (table = 'videosource' ,
822+ tableto = 'channel' ,
823+ fields = ('sourceid' ,)),
824+ init .Join (table = 'programgenres' ,
825+ tableto = 'program' ,
826+ fields = ('chanid' ,'starttime' )),
827+ init .Join (table = 'programrating' ,
828+ tableto = 'program' ,
829+ fields = ('chanid' ,'starttime' )))
830+ return None
803831
804832 if key in ('chanid' ,'title' ,'subtitle' ,
805833 'category' ,'airdate' ,'stars' ,'previouslyshown' ,'stereo' ,
806834 'subtitled' ,'hdtv' ,'closecaptioned' ,'partnumber' ,
807835 'parttotal' ,'seriesid' ,'originalairdate' ,'showtype' ,
808- 'syndicatedepisodenumber' ,'programid' ,'generic' ):
809- return ('%s=%%s' % key , value , 0 )
836+ 'syndicatedepisodenumber' ,'programid' ,'generic' ,
837+ 'category_type' ):
838+ return ('program.%s=?' % key , value , 0 )
810839 if key in ('starttime' ,'endtime' ):
811- return ('%s=%%s' % key , datetime .duck (value ), 0 )
812- if key == 'ondate' :
813- return ('DATE(starttime)=%s' , value , 0 )
840+ return ('program.%s=?' % key , datetime .duck (value ), 0 )
841+ if key == 'dayofweek' :
842+ return ('DAYNAME(program.starttime)=?' , value , 0 )
843+ if key == 'weekday' :
844+ return ('WEEKDAY(program.starttime)<?' , 5 , 0 )
845+ if key in ('first' , 'last' ):
846+ return ('program.%s=?' % key , 1 , 0 )
847+
848+ if key == 'callsign' :
849+ return ('channel.callsign=?' , value , 4 )
850+ if key == 'commfree' :
851+ return ('channel.commmethod=?' , - 2 , 4 )
852+ if key == 'channelgroup' :
853+ return ('channelgroupnames.name=?' , value , 24 )
854+ if key == 'videosource' :
855+ try :
856+ value = int (value )
857+ return ('channel.sourceid=?' , value , 4 )
858+ except :
859+ return ('videosource.name=?' , value , 36 )
860+ if key == 'genre' :
861+ return ('programgenres.genre=?' , value , 64 )
862+ if key == 'rating' :
863+ return ('programrating.rating=?' , value , 128 )
814864 if key == 'cast' :
815865 return ('people.name' , 'credits' , 2 , 0 )
866+
867+ if key .startswith ('fuzzy' ):
868+ if key [5 :] in ('title' , 'subtitle' , 'description' , 'programid' ):
869+ return ('program.%s LIKE ?' % key [5 :], '%' + value + '%' , 0 )
870+ if key [5 :] == 'callsign' :
871+ return ('channel.callsign LIKE ?' , '%' + value + '%' , 4 )
872+ if key .endswith ('date' ):
873+ prefix = {'on' :'=' , 'before' :'<' , 'after' :'>' }
874+ if key [:- 4 ] in prefix :
875+ return ('DATE(program.starttime){0}?' .format (prefix [key [:- 4 ]]),
876+ value , 0 )
877+
816878 if key == 'startbefore' :
817- return ('starttime<%s ' , datetime .duck (value ), 0 )
879+ return ('program. starttime<? ' , datetime .duck (value ), 0 )
818880 if key == 'startafter' :
819- return ('starttime>%s ' , datetime .duck (value ), 0 )
881+ return ('program. starttime>? ' , datetime .duck (value ), 0 )
820882 if key == 'endbefore' :
821- return ('endtime<%s ' , datetime .duck (value ), 0 )
883+ return ('program. endtime<? ' , datetime .duck (value ), 0 )
822884 if key == 'endafter' :
823- return ('endtime>%s ' , datetime .duck (value ), 0 )
885+ return ('program. endtime>? ' , datetime .duck (value ), 0 )
824886 return None
825887
826888 def makePowerRule (self , ruletitle = 'unnamed (Power Search' ,
@@ -845,11 +907,12 @@ def searchRecord(self, init=False, key=None, value=None):
845907 if init :
846908 init .table = 'record'
847909 init .handler = Record
910+ return None
848911
849912 if key in ('type' ,'chanid' ,'starttime' ,'startdate' ,'endtime' ,'enddate' ,
850913 'title' ,'subtitle' ,'category' ,'profile' ,'recgroup' ,
851914 'station' ,'seriesid' ,'programid' ,'playgroup' ,'inetref' ):
852- return ('%s=%%s ' % key , value , 0 )
915+ return ('%s=? ' % key , value , 0 )
853916 return None
854917
855918 @databaseSearch
@@ -867,23 +930,24 @@ def searchInternetContent(self, init=False, key=None, value=None):
867930 if init :
868931 init .table = 'internetcontentarticles'
869932 init .handler = InternetContentArticles
933+ return None
870934
871935 if key in ('feedtitle' ,'title' ,'subtitle' ,'season' ,'episode' ,'url' ,
872936 'type' ,'author' ,'rating' ,'player' ,'width' ,'height' ,
873937 'language' ,'podcast' ,'downloadable' , 'description' ):
874- return ('%s=%%s ' % key , value , 0 )
938+ return ('%s=? ' % key , value , 0 )
875939 if key == 'ondate' :
876- return ('DATE(date)=%s ' , value , 0 )
940+ return ('DATE(date)=? ' , value , 0 )
877941 if key == 'olderthan' :
878- return ('date>%s ' , value , 0 )
942+ return ('date>? ' , value , 0 )
879943 if key == 'newerthan' :
880- return ('date<%s ' , value , 0 )
944+ return ('date<? ' , value , 0 )
881945 if key == 'longerthan' :
882- return ('time<%s ' , value , 0 )
946+ return ('time<? ' , value , 0 )
883947 if key == 'shorterthan' :
884- return ('time>%s ' , value , 0 )
948+ return ('time>? ' , value , 0 )
885949 if key == 'country' :
886- return ('countries LIKE %s ' , '%%%s%%' % value , 0 )
950+ return ('countries LIKE ? ' , '%' + value + '%' , 0 )
887951
888952 def getFrontends (self ):
889953 """
@@ -982,26 +1046,27 @@ def searchVideos(self, init=False, key=None, value=None):
9821046 tableto = 'videometadata' ,
9831047 fieldsfrom = ('intid' ,),
9841048 fieldsto = ('category' ,)))
1049+ return None
9851050
9861051 if key in ('title' ,'subtitle' ,'season' ,'episode' ,'host' ,
9871052 'director' ,'year' ):
988- return ('videometadata.%s=%%s ' % key , value , 0 )
1053+ return ('videometadata.%s=? ' % key , value , 0 )
9891054 vidref = {'cast' :(2 ,0 ), 'genre' :(8 ,2 ), 'country' :(32 ,4 )}
9901055 if key in vidref :
9911056 return ('video%s.%s' % (key ,key ),
9921057 'videometadata%s' % key ,
9931058 vidref [key ][0 ],
9941059 vidref [key ][1 ])
9951060 if key == 'category' :
996- return ('videocategory.%s=%%s ' % key , value , 64 )
1061+ return ('videocategory.%s=? ' % key , value , 64 )
9971062 if key == 'exactfile' :
998- return ('videometadata.filename=%s ' , value , 0 )
1063+ return ('videometadata.filename=? ' , value , 0 )
9991064 if key == 'file' :
1000- return ('videometadata.filename LIKE %s ' , '%' + value , 0 )
1065+ return ('videometadata.filename LIKE ? ' , '%' + value , 0 )
10011066 if key == 'insertedbefore' :
1002- return ('videometadata.insertdate<%s ' , value , 0 )
1067+ return ('videometadata.insertdate<? ' , value , 0 )
10031068 if key == 'insertedafter' :
1004- return ('videometadata.insertdate>%s ' , value , 0 )
1069+ return ('videometadata.insertdate>? ' , value , 0 )
10051070 return None
10061071
10071072class MythVideo ( MythDB ):
0 commit comments