def setSearchTime(): dt = DateTime() date = dt.currentDate() MpGlobal.RecentEpochTime = dt.getEpochTime( date + " 00:00") # return seconds at start of this day MpGlobal.LaunchEpochTime = MpGlobal.RecentEpochTime - ( 14 * 24 * 60 * 60) # date of two weeks ago
def setSearchTime(): dt = DateTime() date = dt.currentDate(); MpGlobal.RecentEpochTime = dt.getEpochTime(date+" 00:00") # return seconds at start of this day MpGlobal.LaunchEpochTime = MpGlobal.RecentEpochTime - (14*24*60*60) # date of two weeks ago
def _compileTerm(self,flag_type,flag,ostr): """ flag_type: either EXIF, ARTIST,PLAYCOUNT ETC flag : OR combination of SEARCH dir and mod. < <= >= > = and . + ! * ostr : relevant string term for a search of flag_type """ if ostr == "": return None ostr = unicode(ostr) cf = ostr[:] rf = None; fptr = None; if flag_type < EnumSong.STRINGTERM: fptr = self._compareTerm_String if (flag_type == EnumSong.SPEC_DATESTD ) : dt = DateTime(flag_type&0xF) cf = dt.getEpochTime(dt.repairDateTime(cf)) rf = cf + 24*60*60 if cf == 0: return None dt = DateTime(flag_type&0xF) ostr = dt.repairDateTime(ostr) if flag&SEARCH.DIR == 0:# if no DIR flags set, set EQ flag flag = flag|SEARCH.GT flag_type = EnumSong.DATESTAMP # change type to standard date format fptr = self._compareSongElement elif (flag_type == EnumSong.SPEC_DATEEU ) : dt = DateTime(flag_type&0xF) # set which format to use for dates, for help check the definition for SPEC_DATESTD, and the enumeration in DateTime cf = dt.getEpochTime(dt.repairDateTime(cf)) # autocomplete the entered date then convert to seconds rf = cf + 24*60*60 if cf == 0: return None dt = DateTime(flag_type&0xF) ostr = dt.repairDateTime(ostr) if flag&SEARCH.DIR == 0:# if no DIR flags set, set EQ flag flag = flag|SEARCH.GT flag_type = EnumSong.DATESTAMP # change type to standard date format fptr = self._compareSongElement elif (flag_type == EnumSong.SPEC_DATEUS ) : dt = DateTime(flag_type&0xF) cf = dt.getEpochTime(dt.repairDateTime(cf)) rf = cf + 24*60*60 if cf == 0: return None dt = DateTime(flag_type&0xF) ostr = dt.repairDateTime(ostr) if flag&SEARCH.DIR == 0:# if no DIR flags set, set EQ flag flag = flag|SEARCH.GT flag_type = EnumSong.DATESTAMP # change type to standard date format fptr = self._compareSongElement elif (flag_type == EnumSong.SPEC_MONTH ) : if flag&SEARCH.DIR == 0:# if no DIR flags set, set EQ flag flag = flag|SEARCH.GT flag_type = EnumSong.DATESTAMP cf = DateTime.now() try : cf -= 30*int(ostr)*24*60*60 rf = cf + 28*24*60*60 ostr = "month: %s"%ostr except: pass fptr = self._compareSongElement elif (flag_type == EnumSong.SPEC_WEEK ) : if flag&SEARCH.DIR == 0:# if no DIR flags set, set EQ flag flag = flag|SEARCH.GT flag_type = EnumSong.DATESTAMP cf = DateTime.now() try : cf -= 7*int(ostr)*24*60*60 rf = cf + 7*24*60*60 ostr = "week: %s"%ostr except: pass fptr = self._compareSongElement elif (flag_type == EnumSong.DATESTAMP) : if flag&SEARCH.DIR == 0:# if no DIR flags set, set EQ flag flag = flag|SEARCH.GT cf = DateTime.now() try : cf -= int(ostr)*24*60*60 rf = cf + 24*60*60 ostr = "day: %s"%ostr except: pass fptr = self._compareSongElement elif (flag_type == EnumSong.DATEADDED) : dt = DateTime(EnumSong.SPEC_DATESTD&0xF) cf = dt.getEpochTime(dt.repairDateTime(cf)) rf = cf + 24*60*60 if cf == 0: return None dt = DateTime(EnumSong.SPEC_DATESTD&0xF) ostr = dt.repairDateTime(ostr) if flag&SEARCH.DIR == 0:# if no DIR flags set, set EQ flag flag = flag|SEARCH.GT fptr = self._compareSongElement elif (flag_type == EnumSong.PATH ) : if cf == u"": return None rf = None fptr = self._compareSongElement elif flag_type >= EnumSong.STRINGTERM and flag_type < EnumSong.NUMTERM : if flag&SEARCH.DIR == 0:# if no DIR flags set, set EQ flag flag = flag|SEARCH.EQ try: cf = int(cf) except: cf = 0 return None rf = None # set the function to do the compare if flag_type == EnumSong.FREQUENCY: fptr = self._compareTerm_Frequency else: fptr = self._compareTerm_Number if flag_type == EnumSong.LENGTH: cf = DateTime.parseTimeDelta(ostr) term = SearchTerm(ostr,flag_type,flag,cf,rf,fptr) self.addTerm(flag&SEARCH.MOD,term)