old_contents: #!/usr/bin/python
  
  """
  tsdv.py - timestamp dv
  sets start/end times of dv files
  
  Gets start from one of:
  the file system time stamp, 
  the first frame of the dv
  the file name (assumes hh:mm:ss.dv format)
  
  Gets end from:
  start + duration based on file size / BBF*FPS
  last frame
  
  """
  
  import  os
  import datetime
  # from dateutil.parser import parse
  
  from process import process
  
  from main.models import Client, Show, Location, Episode, Raw_File, Cut_List
  
  class add_dv(process):
  
      def one_dv(self, dir, dv ):
          
          pathname = os.path.join(dir,dv.filename)
          print pathname
          start=datetime.datetime.strptime(dv.filename,'%Y-%m-%d/%H:%M:%S.dv')
          # dt = dv.filename[:-3]
          # dt.replace('/',' ')
          st = os.stat(pathname)    
  # get start from filesystem create timestamp
          # start=datetime.datetime.fromtimestamp( st.st_mtime )
          # start=parse(dt)
  # use this to adjust for camera clock in wrong timezone
          # start -= datetime.timedelta(hours=2,minutes=0)
          if False and start.day==8:
              if dv.location.slug=='Holladay':
                  print dv.location.slug
                  start -= datetime.timedelta(hours=2,minutes=0)
              else:
                  start -= datetime.timedelta(hours=2,minutes=37)
  
          # calc duration based on filesize
          frames = st.st_size/120000
          fps = float(self.options.fps)
          duration = frames/ fps ## seconds
  
          end = start + datetime.timedelta(seconds=duration)
          
          dv.start = start
          dv.end = end
  
          print dv,start,end
          dv.save()
  
  
      def one_loc(self,location,dir):
        for dv in Raw_File.objects.filter(location=location):
          self.one_dv(dir,dv)
  
      def one_show(self, show):
        for loc in Location.objects.filter(show=show):
          dir=os.path.join(self.show_dir,'dv',loc.slug)
          print show,loc,dir
          self.one_loc(loc, dir)
  
      def add_more_options(self, parser):
          parser.add_option('--fps', default="29.98",
              help='fps 25 for PAL, 29.98 for NTSC, or whatever number you want.' )
  
  if __name__=='__main__': 
      p=add_dv()
      p.main()
  
  
new_contents: #!/usr/bin/python
  
  """
  tsdv.py - timestamp dv
  sets start/end times of dv files
  
  Gets start from one of:
  the file system time stamp, 
  the first frame of the dv
  the file name (assumes hh:mm:ss.dv format)
  
  Gets end from:
  start + duration based on file size / BBF*FPS
  last frame
  
  """
  
  import  os
  import datetime
  # from dateutil.parser import parse
  
  from process import process
  
  from main.models import Client, Show, Location, Episode, Raw_File, Cut_List
  
  class add_dv(process):
  
      def one_dv(self, dir, dv ):
          
          pathname = os.path.join(dir,dv.filename)
          print pathname
          start=datetime.datetime.strptime(dv.filename,'%Y-%m-%d/%H:%M:%S.dv')
          # dt = dv.filename[:-3]
          # dt.replace('/',' ')
          st = os.stat(pathname)    
  # get start from filesystem create timestamp
          # start=datetime.datetime.fromtimestamp( st.st_mtime )
          # start=parse(dt)
  # use this to adjust for camera clock in wrong timezone
          # start -= datetime.timedelta(hours=2,minutes=0)
          if False and start.day==8:
              if dv.location.slug=='Holladay':
                  print dv.location.slug
                  start -= datetime.timedelta(hours=2,minutes=0)
              else:
                  start -= datetime.timedelta(hours=2,minutes=37)
  
          # calc duration based on filesize
          if self.options.format.lower()=='ntsc':
              frame_size = 120000
              fps = 29.98
          else:
              frame_size = 144000
              fps = 25
          frames = st.st_size/frame_size
          duration = frames/fps ## seconds
  
          end = start + datetime.timedelta(seconds=duration)
          
          dv.start = start
          dv.end = end
  
          print dv,start,end
          dv.save()
  
  
      def one_loc(self,location,dir):
        for dv in Raw_File.objects.filter(location=location):
          self.one_dv(dir,dv)
  
      def one_show(self, show):
        for loc in Location.objects.filter(show=show):
          dir=os.path.join(self.show_dir,'dv',loc.slug)
          print show,loc,dir
          self.one_loc(loc, dir)
  
      def add_more_options(self, parser):
          parser.add_option('--format', default="ntsc",
              help='pal or ntsc' )
  
  if __name__=='__main__': 
      p=add_dv()
      p.main()
  
  
subject: replace fps with format