Author: duncan
Date: Thu Jan  4 05:41:43 2007
New Revision: 8925

Modified:
   branches/rel-1/freevo/freevo_config.py
   branches/rel-1/freevo/local_conf.py.example
   branches/rel-1/freevo/src/helpers/recordserver.py
   branches/rel-1/freevo/src/tv/edit_favorite.py
   branches/rel-1/freevo/src/tv/epg_types.py
   branches/rel-1/freevo/src/tv/program_display.py
   branches/rel-1/freevo/src/tv/record_client.py
   branches/rel-1/freevo/src/tv/record_types.py
   branches/rel-1/freevo/src/www/htdocs/edit_favorite.rpy
   branches/rel-1/freevo/src/www/htdocs/favorites.rpy

Log:
[ 1626513 ] Allow prevention of duplicated recordings
Patch from Justin Wetherell and Andrew Flegg applied


Modified: branches/rel-1/freevo/freevo_config.py
==============================================================================
--- branches/rel-1/freevo/freevo_config.py      (original)
+++ branches/rel-1/freevo/freevo_config.py      Thu Jan  4 05:41:43 2007
@@ -1459,6 +1459,12 @@
 # XXX the path doesn't work from the www cgi scripts!
 TV_RECORD_DIR = None
 
+# This will enable duplicate recording detection
+DUPLICATE_DETECTION = None
+
+# This will enable only new episodes to be recorded
+ONLY_NEW_DETECTION = None
+
 #
 # Watching TV
 #

Modified: branches/rel-1/freevo/local_conf.py.example
==============================================================================
--- branches/rel-1/freevo/local_conf.py.example (original)
+++ branches/rel-1/freevo/local_conf.py.example Thu Jan  4 05:41:43 2007
@@ -138,12 +138,12 @@
 # should not be interrupted, then add them to this
 # list. Set to None if a shutdown is always allowed.
 #AUTOSHUTDOWN_PROCESS_LIST = [
-#      'emerge',
-#      'tvgids',
-#      'transcode',
-#      'cdrecord',
-#      'mplayer',
-#      'top'
+#    'emerge',
+#    'tvgids',
+#    'transcode',
+#    'cdrecord',
+#    'mplayer',
+#    'top'
 #]
 
 # DEFAULT_WAKEUP_TIME
@@ -897,7 +897,7 @@
 
 # MPLAYER_AO_DEV      = 'oss:/dev/dsp'  # e.g.: oss,sdl,alsa, see mplayer docs
 
-# MPLAYER_VO_DEV_OPTS = ''             # e.g.: ':some_var=vcal'
+# MPLAYER_VO_DEV_OPTS = ''              # e.g.: ':some_var=vcal'
 
 # DVD_LANG_PREF       = 'en,se,no'      # Order of preferred languages on DVD.
 # DVD_SUBTITLE_PREF   = ''              # Order of preferred subtitles on DVD.
@@ -1028,6 +1028,12 @@
 # XXX the path doesn't work from the www cgi scripts!
 # TV_RECORD_DIR = None
 
+# This will enable duplicate recording detection
+# DUPLICATE_DETECTION = True
+
+# This will enable only new episodes to be recorded
+# ONLY_NEW_DETECTION = True
+
 #
 # Watching TV
 #

Modified: branches/rel-1/freevo/src/helpers/recordserver.py
==============================================================================
--- branches/rel-1/freevo/src/helpers/recordserver.py   (original)
+++ branches/rel-1/freevo/src/helpers/recordserver.py   Thu Jan  4 05:41:43 2007
@@ -27,7 +27,7 @@
 # -----------------------------------------------------------------------
 
 
-import sys, string, random, time, os, re, pwd, stat, threading
+import sys, string, random, time, os, re, pwd, stat, threading, pickle, md5, 
datetime
 import config
 from util import vfs
 
@@ -111,6 +111,7 @@
         # XXX: In the future we should have one lock per VideoGroup.
         self.tv_lock_file = None
         self.vg = None
+        self.previouslyRecordedShows = None
 
 
     def isRecording(self):
@@ -270,7 +271,141 @@
 
         return TRUE
 
- 
+    #
+    # Load the saved set of recorded shows
+    #
+    def loadPreviouslyRecordedShows(self):
+        if self.previouslyRecordedShows:
+            return
+
+        cacheFile = config.FREEVO_CACHEDIR + "/previouslyRecorded.pickle"
+        try:
+            self.previouslyRecordedShows = pickle.load(open(cacheFile, "r"))
+        except IOError:
+            self.previouslyRecordedShows = {}
+            pass
+
+    #
+    # Save the set of recorded shows
+    #
+    def savePreviouslyRecordedShows(self):
+        if not self.previouslyRecordedShows:
+            return
+
+        cacheFile=config.FREEVO_CACHEDIR+"/previouslyRecorded.pickle"
+        pickle.dump(self.previouslyRecordedShows, open(cacheFile,"w"))
+
+    #
+    # Return true if this is a new episode of 'prog'
+    #
+    def newEpisode(self, prog=None):
+        todayStr = datetime.date.today().strftime('%Y%m%d')
+        progStr = str(prog.date)
+        _debug_('Program Date: "%s"' % progStr)
+        _debug_('Todays Date : "%s"' % todayStr)
+        if (len(progStr)==8):
+           _debug_('Good date format')
+           #Year
+           todaysYear=(todayStr[0:4])
+           progYear=(progStr[0:4])
+           #Month
+           todaysMonth=(todayStr[4:2])
+           progMonth=(progStr[4:2])
+           #Day
+           todaysDay=(todayStr[6:2])
+           progDay=(progStr[6:2])
+           if todaysYear > progYear:
+              #program from a previous year
+              return FALSE
+           elif progYear > todaysYear:
+              #program in the future
+              return TRUE
+           else:
+              _debug_('Same year')
+              #program in the same year
+              if todaysMonth > progMonth:
+                 #program in a previous month
+                 return FALSE
+              elif progMonth > todaysMonth:
+                 #program in the future
+                 return TRUE
+              else:
+                 _debug_('Same month')
+                 #program in the same month
+                 if todaysDay > progDay:
+                    #program was previous aired this month
+                    return FALSE
+                 else:
+                    _debug_('Same day or in the upcoming month')
+                    #program is today or in the upcoming days
+                    return TRUE
+        else:
+           _debug_('No good date format, assuming new Episode to be on the 
safe side')
+           return TRUE
+
+    #
+    # Shrink a string by removing all spaces and making it
+    # lower case and then returning the MD5 digest of it.
+    #
+    def shrink(self, text):
+       if text:
+           text = md5.new(text.lower().replace(' ', '')).hexdigest()
+       else:
+           text = ''
+
+       return text
+
+    #
+    # Return the key to be used for a given prog in the
+    # previouslyRecordedShows hashtable.
+    #
+    def getPreviousRecordingKey(self, prog):
+        shrunkTitle = self.shrink(prog.title)
+        shrunkSub   = self.shrink(prog.sub_title)
+        shrunkDesc  = self.shrink(prog.desc);
+        return ('%s-%s-%s' % (shrunkTitle, shrunkSub, shrunkDesc), \
+                '%s-%s-'   % (shrunkTitle, shrunkSub),              \
+                '%s--%s'   % (shrunkTitle, shrunkDesc))
+
+    #
+    # Get a previous recording, or None if none.
+    #
+    def getPreviousRecording(self, prog):
+        try:
+            return 
self.previouslyRecordedShows[self.getPreviousRecordingKey(prog)]
+        except KeyError:
+            return None
+
+    #
+    # Remove a duplicate recording
+    #
+    def removeDuplicate(self, prog=None):
+        self.loadPreviouslyRecordedShows()
+        previous = self.getPreviousRecording(prog)
+        if previous:
+           _debug_('Found duplicate, removing')
+           del 
self.previouslyRecordedShows[self.getPreviousRecordingKey(previous)]
+           self.savePreviouslyRecordedShows()
+
+    #
+    # Identify if the given programme is a duplicate. If not,
+    # record it as previously recorded.
+    #
+    def duplicate(self, prog=None):
+        self.loadPreviouslyRecordedShows()
+        previous = self.getPreviousRecording(prog)
+        if previous:
+            _debug_('Found duplicate for "%s", "%s", "%s", not adding' % \
+            (prog.title, prog.sub_title, prog.desc))
+            return TRUE
+        _debug_('No previous recordings for "%s", "%s", "%s", adding to hash 
and saving' % \
+        (prog.title, prog.sub_title, prog.desc))
+        self.previouslyRecordedShows[self.getPreviousRecordingKey(prog)] = prog
+        for key in self.getPreviousRecordingKey(prog):
+            self.previouslyRecordedShows[key] = prog.start
+        self.savePreviouslyRecordedShows()
+        return FALSE
+
     def scheduleRecording(self, prog=None):
         global guide
 
@@ -288,9 +423,44 @@
                 _debug_('scheduleRecording: "%s"' % (prog))
                 prog.tunerid = chan.tunerid
     
-        scheduledRecordings = self.getScheduledRecordings()
-        scheduledRecordings.addProgram(prog, tv_util.getKey(prog))
-        self.saveScheduledRecordings(scheduledRecordings)
+        if config.DUPLICATE_DETECTION and not 
self.doesFavoriteAllowDuplicates(prog):
+           _debug_('Duplicate Detection enabled 1')
+           if not self.duplicate(prog):
+              if config.ONLY_NEW_DETECTION and 
self.doesFavoriteRecordOnlyNewEpisodes(prog):
+                 _debug_('OnlyNew Episode Detection enabled 1')
+                 if self.newEpisode(prog):
+                    _debug_('New Episode')
+                    scheduledRecordings = self.getScheduledRecordings()
+                    scheduledRecordings.addProgram(prog, tv_util.getKey(prog))
+                    self.saveScheduledRecordings(scheduledRecordings)
+                 else:
+                    _debug_('Old Episode')
+              else:
+                 _debug_('OnlyNew Episode Detection disabled or Favorite 
allows all Episodes 1')
+                 scheduledRecordings = self.getScheduledRecordings()
+                 scheduledRecordings.addProgram(prog, tv_util.getKey(prog))
+                 self.saveScheduledRecordings(scheduledRecordings)
+                 _debug_('Added Episode')
+           else:
+              return (FALSE, 'duplicate recording')
+        else:
+           _debug_('Duplicate Detection is disabled or Favorite allows 
duplicates 2')
+           if config.ONLY_NEW_DETECTION and 
self.doesFavoriteRecordOnlyNewEpisodes(prog):
+              _debug_('OnlyNew Detection enabled 2')
+              if self.newEpisode(prog):
+                 _debug_('New Episode')
+                 scheduledRecordings = self.getScheduledRecordings()
+                 scheduledRecordings.addProgram(prog, tv_util.getKey(prog))
+                 self.saveScheduledRecordings(scheduledRecordings)
+              else:
+                 _debug_('Old Episode')
+
+           else:
+              _debug_('OnlyNew Episode Detection disabled 2')
+              scheduledRecordings = self.getScheduledRecordings()
+              scheduledRecordings.addProgram(prog, tv_util.getKey(prog))
+              self.saveScheduledRecordings(scheduledRecordings)
+              _debug_('Added Episode')
 
         # check, maybe we need to start right now
         self.checkToRecord()
@@ -318,6 +488,8 @@
             print 'prog.isRecording:', e
             recording = FALSE
 
+        if config.DUPLICATE_DETECTION:
+           self.removeDuplicate(prog)
         scheduledRecordings = self.getScheduledRecordings()
         scheduledRecordings.removeProgram(prog, tv_util.getKey(prog))
         self.saveScheduledRecordings(scheduledRecordings)
@@ -562,7 +734,7 @@
     
         (status, favs) = self.getFavorites()
         priority = len(favs) + 1
-        fav = tv.record_types.Favorite(name, prog, exactchan, exactdow, 
exacttod, priority)
+        fav = tv.record_types.Favorite(name, prog, exactchan, exactdow, 
exacttod, priority, allowDuplicates, onlyNew)
     
         scheduledRecordings = self.getScheduledRecordings()
         scheduledRecordings.addFavorite(fav)
@@ -572,7 +744,7 @@
         return (TRUE, 'favorite added')
     
     
-    def addEditedFavorite(self, name, title, chan, dow, mod, priority):
+    def addEditedFavorite(self, name, title, chan, dow, mod, priority, 
allowDuplicates, onlyNew):
         fav = tv.record_types.Favorite()
     
         fav.name = name
@@ -581,6 +753,8 @@
         fav.dow = dow
         fav.mod = mod
         fav.priority = priority
+        fav.allowDuplicates = allowDuplicates
+        fav.onlyNew = onlyNew
     
         scheduledRecordings = self.getScheduledRecordings()
         scheduledRecordings.addFavorite(fav)
@@ -687,7 +861,24 @@
     
         # if we get this far prog is not a favorite
         return (FALSE, 'not a favorite')
+
+    def doesFavoriteRecordOnlyNewEpisodes(self, prog, favs=None):
+        if not favs:
+           (status, favs) = self.getFavorites()
+        for fav in favs.values():
+            if Unicode(prog.title).lower().find(Unicode(fav.title).lower()) >= 
0:
+               _debug_('NEW: %s'%fav.onlyNew)
+               if fav.onlyNew == '1':
+                  return TRUE 
     
+    def doesFavoriteAllowDuplicates(self, prog, favs=None):
+        if not favs:
+           (status, favs) = self.getFavorites()
+        for fav in favs.values():
+            if Unicode(prog.title).lower().find(Unicode(fav.title).lower()) >= 
0:
+               _debug_('DUP: %s'%fav.allowDuplicates)
+               if fav.allowDuplicates == '1':
+                  return TRUE
     
     def removeFavoriteFromSchedule(self, fav):
         # TODO: make sure the program we remove is not
@@ -920,12 +1111,12 @@
         return (status, message)
 
 
-    def xmlrpc_addEditedFavorite(self, name, title, chan, dow, mod, priority):
+    def xmlrpc_addEditedFavorite(self, name, title, chan, dow, mod, priority, 
allowDuplicates, onlyNew):
         (status, message) = (FALSE, 'RecordServer::addEditedFavorite: cannot 
acquire lock')
         try:
             self.lock.acquire()
             (status, response) = self.addEditedFavorite(unjellyFromXML(name), \
-            unjellyFromXML(title), chan, dow, mod, priority)
+            unjellyFromXML(title), chan, dow, mod, priority, allowDuplicates, 
onlyNew)
             message = 'RecordServer::addEditedFavorite: %s' % response
         finally:
             self.lock.release()

Modified: branches/rel-1/freevo/src/tv/edit_favorite.py
==============================================================================
--- branches/rel-1/freevo/src/tv/edit_favorite.py       (original)
+++ branches/rel-1/freevo/src/tv/edit_favorite.py       Thu Jan  4 05:41:43 2007
@@ -80,7 +80,7 @@
             else:
                 self.priority = 1
 
-            self.fav = Favorite(subject.title, subject, TRUE, TRUE, TRUE, 
self.priority)
+            self.fav = Favorite(subject.title, subject, TRUE, TRUE, TRUE, 
self.priority, TRUE, FALSE)
         else:
             self.fav = subject
             self.oldname = self.fav.name
@@ -311,7 +311,9 @@
                              self.chan_box.list.get_selected_item().value,
                              self.dow_box.list.get_selected_item().value, 
                              self.tod_box.list.get_selected_item().value, 
-                             self.fav.priority)
+                             self.fav.priority,
+                             self.fav.allowDuplicates,
+                             self.fav.onlyNew)
                 if result:
                     #tv.view_favorites.ViewFavorites(parent=self.parent, 
text='Favorites').show()
                     self.destroy()

Modified: branches/rel-1/freevo/src/tv/epg_types.py
==============================================================================
--- branches/rel-1/freevo/src/tv/epg_types.py   (original)
+++ branches/rel-1/freevo/src/tv/epg_types.py   Thu Jan  4 05:41:43 2007
@@ -64,6 +64,9 @@
     date       = None
     scheduled  = None
     overlap    = None
+    previouslyRecorded = None
+    allowDuplicates = None
+    onlyNew = None
 
 
     def __init__(self):
@@ -83,6 +86,9 @@
         # to a boolean type. 
         self.scheduled  = 0
         self.overlap    = 0
+        self.previouslyRecorded = 0
+        self.allowDuplicates = 1
+        self.onlyNew = 0
 
 
     def __str__(self):

Modified: branches/rel-1/freevo/src/tv/program_display.py
==============================================================================
--- branches/rel-1/freevo/src/tv/program_display.py     (original)
+++ branches/rel-1/freevo/src/tv/program_display.py     Thu Jan  4 05:41:43 2007
@@ -64,6 +64,10 @@
         else:
             self.scheduled = False
 
+        self.allowDuplicates = prog.allowDuplicates
+
+        self.onlyNew = prog.onlyNew
+
         self.overlap = prog.overlap
 
         self.favorite = False
@@ -137,7 +141,7 @@
 
 
     def add_favorite(self, arg=None, menuw=None):
-        fav = Favorite(self.prog.title, self.prog, True, True, True, -1)
+        fav = Favorite(self.prog.title, self.prog, True, True, True, -1, True, 
False)
         fav_item = FavoriteItem(self, fav, fav_action='add')
         fav_item.display_favorite(menuw=menuw)
 
@@ -216,6 +220,14 @@
         self.name  = self.origname = fav.name
         self.title = fav.title
         self.fav_action = fav_action
+        if hasattr(fav,'allowDuplicates'):
+           self.allowDuplicates = fav.allowDuplicates
+        else:
+           self.allowDuplicates = 1
+        if hasattr(fav,'onlyNew'):
+           self.onlyNew = fav.onlyNew
+        else:
+           self.onlyNew = 0
 
         self.week_days = (_('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), 
_('Sat'), _('Sun'))
 
@@ -250,6 +262,10 @@
         items.append(menu.MenuItem(_('Modify channel'), 
action=self.mod_channel))
         items.append(menu.MenuItem(_('Modify day of week'), 
action=self.mod_day))
         items.append(menu.MenuItem(_('Modify time of day'), 
action=self.mod_time))
+        if config.DUPLICATE_DETECTION:
+           items.append(menu.MenuItem(_('Modify duplicate flag'), 
action=self.mod_dup))
+        if config.ONLY_NEW_DETECTION:
+           items.append(menu.MenuItem(_('Modify episodes flag'), 
action=self.mod_new))
 
         # XXX: priorities aren't quite supported yet
         if 0:
@@ -281,6 +297,23 @@
 
         self.menuw.refresh()
 
+    def mod_dup(self, arg=None, menuw=None):
+        items = []
+        items.append(menu.MenuItem('Allow Duplicates', 
action=self.alter_prop,arg=('dup', 'True')))
+        items.append(menu.MenuItem('Prevent Duplicates', 
action=self.alter_prop,arg=('dup', 'False')))
+        favorite_menu = menu.Menu(_('Modify Duplicate Flag'), items,item_types 
= 'tv favorite menu')
+        favorite_menu.infoitem = self
+        menuw.pushmenu(favorite_menu)
+        menuw.refresh()
+
+    def mod_new(self, arg=None, menuw=None):
+        items = []
+        items.append(menu.MenuItem('All Episodes', 
action=self.alter_prop,arg=('new', 'False')))
+        items.append(menu.MenuItem('Only New Episodes', 
action=self.alter_prop,arg=('new', 'True')))
+        favorite_menu = menu.Menu(_('Modify Only New Flag'), items,item_types 
= 'tv favorite menu')
+        favorite_menu.infoitem = self
+        menuw.pushmenu(favorite_menu)
+        menuw.refresh()
 
     def mod_channel(self, arg=None, menuw=None):
         items = []
@@ -328,6 +361,22 @@
                                     gmtime(float(val * 60)))
                 self.fav.mod = val
 
+        elif prop == 'dup':
+             if val == 'True':
+                self.allowDuplicates=TRUE
+                self.fav.allowDuplicates=TRUE
+             else:
+                self.allowDuplicates=FALSE
+                self.fav.allowDuplicates=FALSE
+
+        elif prop == 'new':
+             if val == 'True':
+                self.onlyNew=TRUE
+                self.fav.onlyNew=TRUE
+             else:
+                self.onlyNew=FALSE
+                self.fav.onlyNew=FALSE
+
         if menuw:  
             menuw.back_one_menu(arg='reload')
 
@@ -376,15 +425,21 @@
             result = True
 
         if result:
-            (result, msg) = record_client.addEditedFavorite(self.fav.name, 
+           if not config.DUPLICATE_DETECTION or not 
hasattr(self.fav,'allowDuplicates'):
+              self.fav.allowDuplicates = 1
+           if not config.ONLY_NEW_DETECTION or not hasattr(self.fav,'onlyNew'):
+              self.fav.onlyNew = 0
+           (result, msg) = record_client.addEditedFavorite(self.fav.name, 
                                                             self.fav.title, 
                                                             self.fav.channel, 
                                                             self.fav.dow, 
                                                             self.fav.mod, 
-                                                            self.fav.priority)
-            if not result:
+                                                            self.fav.priority,
+                                                            
self.fav.allowDuplicates,
+                                                            self.fav.onlyNew)
+           if not result:
                 AlertBox(text=_('Save Failed, favorite was lost')+(': %s' % 
msg)).show()
-            else:
+           else:
                 self.fav_action = 'edit'
                 if menuw:  
                     menuw.back_one_menu(arg='reload')

Modified: branches/rel-1/freevo/src/tv/record_client.py
==============================================================================
--- branches/rel-1/freevo/src/tv/record_client.py       (original)
+++ branches/rel-1/freevo/src/tv/record_client.py       Thu Jan  4 05:41:43 2007
@@ -168,11 +168,11 @@
     return (status, message) 
 
 
-def addEditedFavorite(name, title, chan, dow, mod, priority):
+def addEditedFavorite(name, title, chan, dow, mod, priority, allowDuplicates, 
onlyNew):
     try:
         (status, message) = \
             server.addEditedFavorite(jellyToXML(name), \
-            jellyToXML(title), chan, dow, mod, priority)
+            jellyToXML(title), chan, dow, mod, priority, allowDuplicates, 
onlyNew)
     except Exception, e:
         print e
         traceback.print_exc()

Modified: branches/rel-1/freevo/src/tv/record_types.py
==============================================================================
--- branches/rel-1/freevo/src/tv/record_types.py        (original)
+++ branches/rel-1/freevo/src/tv/record_types.py        Thu Jan  4 05:41:43 2007
@@ -134,7 +134,7 @@
 class Favorite:
 
     def __init__(self, name=None, prog=None, exactchan=FALSE, exactdow=FALSE, 
-                 exacttod=FALSE, priority=0):
+                 exacttod=FALSE, priority=0, allowDuplicates=TRUE, 
onlyNew=FALSE):
         self.TYPES_VERSION = TYPES_VERSION
         translation_table = \
                             '                ' \
@@ -158,6 +158,8 @@
         if name:
             self.name = string.translate(name,translation_table)
         self.priority = priority
+        self.allowDuplicates = allowDuplicates
+        self.onlyNew = onlyNew
 
         if prog:
             self.title = prog.title

Modified: branches/rel-1/freevo/src/www/htdocs/edit_favorite.rpy
==============================================================================
--- branches/rel-1/freevo/src/www/htdocs/edit_favorite.rpy      (original)
+++ branches/rel-1/freevo/src/www/htdocs/edit_favorite.rpy      Thu Jan  4 
05:41:43 2007
@@ -33,6 +33,7 @@
 from tv.record_types import Favorite
 import tv.epg_xmltv
 import tv.record_client as ri
+import config
 
 from www.web_types import HTMLResource, FreevoResource
 
@@ -71,7 +72,7 @@
         if action == 'add' and chan and start:
             (result, prog) = ri.findProg(chan, start)
 
-           if not result:
+            if not result:
                 fv.printHeader('Edit Favorite', 'styles/main.css')
                 fv.printMessagesFinish(
                     [ '<b>'+_('ERROR') + '</b>: ' + \
@@ -89,7 +90,7 @@
 
             priority = num_favorites + 1
 
-            fav = Favorite(prog.title, prog, TRUE, TRUE, TRUE, priority)
+            fav = Favorite(prog.title, prog, TRUE, TRUE, TRUE, priority, FALSE)
         elif action == 'edit' and name:
             (result, fav) = ri.getFavorite(name)
         else:
@@ -128,6 +129,10 @@
         fv.tableCell(_('Channel'), 'class="guidehead" colspan="1"')
         fv.tableCell(_('Day of week'), 'class="guidehead" colspan="1"')
         fv.tableCell(_('Time of day'), 'class="guidehead" colspan="1"')
+        if config.DUPLICATE_DETECTION:
+           fv.tableCell(_('Duplicates'), 'class="guidehead" colspan="1"')
+        if config.ONLY_NEW_DETECTION:
+           fv.tableCell(_('Episodes'), 'class="guidehead" colspan="1"')
         fv.tableCell(_('Action'), 'class="guidehead" colspan="1"')
         fv.tableRowClose()
 
@@ -223,6 +228,28 @@
         """
         fv.tableCell(cell, 'class="'+status+'" colspan="1"')
 
+        if config.DUPLICATE_DETECTION:
+           if hasattr(fav, 'allowDuplicates'):
+              cell = '\n<select name="allowDuplicates" selected="%s">\n' % \
+              fav.allowDuplicates
+           else:
+              cell = '\n<select name="allowDuplicates">\n'
+           cell += '          <option value="1">'+_('ALLOW')+'</option>\n'
+           cell += '          <option value="0">'+_('PREVENT')+'</option>\n'
+           cell += '</select>\n'
+           fv.tableCell(cell, 'class="'+status+'" colspan="1"')
+
+        if config.ONLY_NEW_DETECTION:
+           if hasattr(fav, 'onlyNew'):
+              cell = '\n<select name="onlyNew" selected="%s">\n' % fav.onlyNew
+           else:
+              cell = '\n<select name="onlyNew">\n'
+           cell += '          <option value="0">'+_('ALL')+'</option>\n'
+           cell += '          <option value="1">'+_('ONLY NEW')+'</option>\n'
+           cell += '</select>\n'
+           fv.tableCell(cell, 'class="'+status+'" colspan="1"')
+
+
         # cell = '\n<select name="priority" selected="%s">\n' % fav.priority
         # for i in range(num_favorites+1):
         #     cell += '  <option value="%s">%s</option>\n' % (i+1, i+1)

Modified: branches/rel-1/freevo/src/www/htdocs/favorites.rpy
==============================================================================
--- branches/rel-1/freevo/src/www/htdocs/favorites.rpy  (original)
+++ branches/rel-1/freevo/src/www/htdocs/favorites.rpy  Thu Jan  4 05:41:43 2007
@@ -30,6 +30,7 @@
 
 import sys, time, string
 import urllib
+import config
 
 import tv.record_client as ri
 import util.tv_util as tv_util
@@ -64,15 +65,20 @@
         dow = fv.formValue(form, 'dow')
         mod = fv.formValue(form, 'mod')
         priority = fv.formValue(form, 'priority')
-
+        allowDuplicates = 1
+        onlyNew = 0
+        if config.DUPLICATE_DETECTION:
+           allowDuplicates = fv.formValue(form, 'allowDuplicates')
+        if config.ONLY_NEW_DETECTION:
+           onlyNew = fv.formValue(form, 'onlyNew')
 
         if action == 'remove':
             ri.removeFavorite(name)
         elif action == 'add':
-            ri.addEditedFavorite(name, title, chan, dow, mod, priority)
+            ri.addEditedFavorite(name, title, chan, dow, mod, priority, 
allowDuplicates, onlyNew)
         elif action == 'edit':
             ri.removeFavorite(oldname)
-            ri.addEditedFavorite(name, title, chan, dow, mod, priority)
+            ri.addEditedFavorite(name, title, chan, dow, mod, priority, 
allowDuplicates, onlyNew)
         elif action == 'bump':
             ri.adjustPriority(name, priority)
         else:
@@ -100,6 +106,10 @@
         fv.tableCell(_('Channel'), 'class="guidehead" colspan="1"')
         fv.tableCell(_('Day of week'), 'class="guidehead" colspan="1"')
         fv.tableCell(_('Time of day'), 'class="guidehead" colspan="1"')
+        if config.DUPLICATE_DETECTION:
+           fv.tableCell(_('Duplicates'), 'class="guidehead" colspan="1"')
+        if config.ONLY_NEW_DETECTION:
+           fv.tableCell(_('Episodes'), 'class="guidehead" colspan="1"')
         fv.tableCell(_('Actions'), 'class="guidehead" colspan="1"')
         fv.tableCell(_('Priority'), 'class="guidehead" colspan="1"')
         fv.tableRowClose()
@@ -131,6 +141,26 @@
                 cell = _('ANY')
             fv.tableCell(cell, 'class="'+status+'" colspan="1"')
 
+            if config.DUPLICATE_DETECTION:
+               (tempStatus, tempFav) = ri.getFavorite(fav.title)
+               if hasattr(tempFav,'allowDuplicates') and 
int(tempFav.allowDuplicates) == 1:
+                  cell = 'ALLOW'
+               elif hasattr(tempFav,'allowDuplicates') and 
int(tempFav.allowDuplicates) == 0:
+                  cell = 'PREVENT'
+               else:
+                  cell = 'NONE'
+               fv.tableCell(cell, 'class="'+status+'" colspan="1"')
+
+            if config.ONLY_NEW_DETECTION:
+               (tempStatus, tempFav) = ri.getFavorite(fav.title)
+               if hasattr(tempFav,'onlyNew') and int(tempFav.onlyNew) == 1:
+                  cell = 'ONLY NEW'
+               elif hasattr(tempFav,'onlyNew') and int(tempFav.onlyNew) == 0:
+                  cell = 'ALL'
+               else:
+                  cell = 'NONE'
+               fv.tableCell(cell, 'class="'+status+'" colspan="1"')
+
             fname_esc = urllib.quote(String(fav.name.replace('&','%26')))
             # cell = '<input type="hidden" name="action" value="%s">' % action
             cell = ('<a 
href="edit_favorite.rpy?action=edit&name=%s">'+_('Edit')+'</a>, ') % fname_esc

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to