<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -20,6 +20,13 @@ class ProgrammesController &lt; ApplicationController
       strDescription &lt;&lt; &quot;on channel #{Channel.find(params[:channel]).xmltvname}&quot;
     end
 
+    if params[:recorded]
+      oProgrammes = []
+
+      strConditions &lt;&lt; &quot;id in (select programme_id from Episodes where recording_status IN ('recorded'))&quot;
+      strDescription &lt;&lt; &quot;recorded&quot;
+    end
+
     if params[:search]
       strConditions &lt;&lt; 'title like ?'
       strParams &lt;&lt; (&quot;%&quot; + params[:search] + &quot;%&quot;)
@@ -128,4 +135,26 @@ class ProgrammesController &lt; ApplicationController
       format.xml  { head :ok }
     end
   end
+
+  def deleterecordings
+    @programme = Programme.find(params[:id])
+    @programme.episodes.each do |oEpisode|
+      if ['recorded', 'recording_failed', 'recording_aborted'].index( oEpisode.recording_status)
+        oEpisode.destroy
+      end
+    end
+
+    @programme = Programme.find_by_id(params[:id])
+    if @programme
+      respond_to do |format|
+        format.html { redirect_to( @programme) }
+        format.xml  { render :xml =&gt; @programme.errors, :status =&gt; :unprocessable_entity }
+      end
+    else
+      respond_to do |format|
+        format.html { redirect_to(programmes_url) }
+        format.xml  { head :ok }
+      end
+    end
+  end
 end</diff>
      <filename>app/controllers/programmes_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -51,6 +51,7 @@
           &lt;%= tab( '', 'Listings', {:controller =&gt; :Listings, :action =&gt; :channels}) %&gt;
           &lt;%= tab( '', 'Channels', {:controller =&gt; :channels, :action =&gt; :index}) %&gt;
           &lt;%= tab( '', 'Recordings', {:controller =&gt; :episodes, :action =&gt; :index, :recorded =&gt; true}) %&gt;
+          &lt;%= tab( '', 'Recordings', {:controller =&gt; :programmes, :action =&gt; :index, :recorded =&gt; true}) %&gt;
           &lt;%= tab( '', 'Jobs', {:controller =&gt; :episodes, :action =&gt; :index, :recording =&gt; true}) %&gt;
           &lt;%= tab( '', 'Search', search_programmes_url) %&gt;
         &lt;/ul&gt;</diff>
      <filename>app/views/layouts/application.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,7 @@
 &lt;p&gt;
   &lt;b&gt;Category:&lt;/b&gt;
   &lt;%= link_to @programme.category.name, :controller =&gt; :programmes, :action =&gt; :index, :category =&gt; @programme.category_id %&gt;
+  &lt;%= button_to &quot;Delete Recordings&quot;, :controller =&gt; :programmes, :action =&gt; :deleterecordings, :id =&gt; @programme, :confirm =&gt; &quot;Really Delete?&quot; %&gt;
 &lt;/p&gt;
 
 &lt;% form_for(@programme) do |f| %&gt;</diff>
      <filename>app/views/programmes/show.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -2,12 +2,18 @@
   &lt;tr&gt;
     &lt;th&gt;Title&lt;/th&gt;
     &lt;th&gt;Category&lt;/th&gt;
+    &lt;% if params[:recorded] %&gt;
+      &lt;th&gt;Recorded&lt;/th&gt;
+    &lt;% end %&gt;
   &lt;/tr&gt;
 
 &lt;% for programme in programmes %&gt;
   &lt;tr&gt;
     &lt;td&gt;&lt;%= link_to programme.title, :controller =&gt; :programmes, :action =&gt; :show, :id =&gt; programme %&gt;&lt;/td&gt;
     &lt;td&gt;&lt;%= programme.category ? link_to( programme.category.name, :action =&gt; :index, :category =&gt; programme.category) : '' %&gt;&lt;/td&gt;
+    &lt;% if params[:recorded] %&gt;
+      &lt;td&gt;&lt;%= Episode.find(:all, :conditions =&gt; [&quot;programme_id = ? and recording_status = 'recorded'&quot;, programme]).count %&gt;&lt;/td&gt;
+    &lt;% end %&gt;
   &lt;/tr&gt;
 &lt;% end %&gt;
 &lt;/table&gt;</diff>
      <filename>app/views/shared/_programmes.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@ ActionController::Routing::Routes.draw do |map|
 
   map.resources :channels
 
-  map.resources :programmes, :collection =&gt; { :search =&gt; :any }
+  map.resources :programmes, :collection =&gt; { :search =&gt; :any }, :member =&gt; { :deleterecordings =&gt; :any}
 
   # The priority is based upon order of creation: first created -&gt; highest priority.
 </diff>
      <filename>config/routes.rb</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>db/production.sqlite3</filename>
    </modified>
    <modified>
      <diff>@@ -36,6 +36,8 @@ class RecordEpisode
           nDuration = @oEpisode.ending.to_time - oNow.to_time
         end
 
+        nDuration += (5 * 60)  # keep missing end of pappa pig
+
         #
         # Ideal time to take a snapshot
         #</diff>
      <filename>lib/Scheduler.rb</filename>
    </modified>
    <modified>
      <diff>@@ -27,7 +27,7 @@ describe RecordEpisode do
     oRecordEpisode = RecordEpisode.new( oEpisode)
 
     Kernel.should_not_receive(:sleep)
-    Kernel.should_receive(:system).with(&quot;mencoder dvb://\&quot;2@CrudTV\&quot; -idx -oac copy -ovc copy -endpos 1800.0 -o \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.avi\&quot; &gt;&gt; /tmp/pctv.log&quot;).and_return(true)
+    Kernel.should_receive(:system).with(&quot;mencoder dvb://\&quot;2@CrudTV\&quot; -idx -oac copy -ovc copy -endpos 2100.0 -o \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.avi\&quot; &gt;&gt; /tmp/pctv.log&quot;).and_return(true)
     Kernel.should_receive(:system).with( &quot;ffmpeg -i \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.avi\&quot; -target pal-dvd -vcodec copy -acodec copy \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.mpeg\&quot;&quot;)
     Kernel.should_receive(:system).with(&quot;ffmpeg -itsoffset -180.0 -i \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.mpeg\&quot; -vframes 1 -an -f mjpeg -s 160x90 \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.mpeg.jpg\&quot;&quot;).and_return(true)
 
@@ -45,7 +45,7 @@ describe RecordEpisode do
     # Duration is shorter because we missed the start
     #
     Kernel.should_receive(:sleep).with(120).and_return(true)
-    Kernel.should_receive(:system).with(&quot;mencoder dvb://\&quot;2@CrudTV\&quot; -idx -oac copy -ovc copy -endpos 1980.0 -o \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.avi\&quot; &gt;&gt; /tmp/pctv.log&quot;).and_return(true)
+    Kernel.should_receive(:system).with(&quot;mencoder dvb://\&quot;2@CrudTV\&quot; -idx -oac copy -ovc copy -endpos 2280.0 -o \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.avi\&quot; &gt;&gt; /tmp/pctv.log&quot;).and_return(true)
     Kernel.should_receive(:system).with( &quot;ffmpeg -i \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.avi\&quot; -target pal-dvd -vcodec copy -acodec copy \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.mpeg\&quot;&quot;)
     Kernel.should_receive(:system).with(&quot;ffmpeg -itsoffset -480.0 -i \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.mpeg\&quot; -vframes 1 -an -f mjpeg -s 160x90 \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.mpeg.jpg\&quot;&quot;).and_return(true)
 
@@ -62,7 +62,7 @@ describe RecordEpisode do
     #
     # Duration is shorter because we missed the start
     #
-    Kernel.should_receive(:system).with(&quot;mencoder dvb://\&quot;2@CrudTV\&quot; -idx -oac copy -ovc copy -endpos 900.0 -o \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.avi\&quot; &gt;&gt; /tmp/pctv.log&quot;).and_return(true)
+    Kernel.should_receive(:system).with(&quot;mencoder dvb://\&quot;2@CrudTV\&quot; -idx -oac copy -ovc copy -endpos 1200.0 -o \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.avi\&quot; &gt;&gt; /tmp/pctv.log&quot;).and_return(true)
     Kernel.should_receive(:system).with( &quot;ffmpeg -i \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.avi\&quot; -target pal-dvd -vcodec copy -acodec copy \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.mpeg\&quot;&quot;)
     Kernel.should_receive(:system).with(&quot;ffmpeg -itsoffset -0 -i \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.mpeg\&quot; -vframes 1 -an -f mjpeg -s 160x90 \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.mpeg.jpg\&quot;&quot;).and_return(true)
 
@@ -77,7 +77,7 @@ describe RecordEpisode do
     oRecordEpisode = RecordEpisode.new( oEpisode)
 
     Kernel.should_not_receive(:sleep)
-    Kernel.should_receive(:system).once.ordered.with(&quot;mencoder dvb://\&quot;2@CrudTV\&quot; -idx -oac copy -ovc copy -endpos 1800.0 -o \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.avi\&quot; &gt;&gt; /tmp/pctv.log&quot;).and_return(false)
+    Kernel.should_receive(:system).once.ordered.with(&quot;mencoder dvb://\&quot;2@CrudTV\&quot; -idx -oac copy -ovc copy -endpos 2100.0 -o \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.avi\&quot; &gt;&gt; /tmp/pctv.log&quot;).and_return(false)
     Kernel.should_not_receive(:system).with(/ffmpeg/)
 
     oRecordEpisode.record( DateTime.new( 2008, 11, 10, 7, 30, 0))
@@ -93,7 +93,7 @@ describe RecordEpisode do
     oRecordEpisode = RecordEpisode.new( oEpisode)
 
     Kernel.should_not_receive(:sleep)
-    Kernel.should_receive(:system).once.ordered.with(&quot;mencoder dvb://\&quot;2@CrudTV\&quot; -idx -oac copy -ovc copy -endpos 1800.0 -o \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.avi\&quot; &gt;&gt; /tmp/pctv.log&quot;).and_return(false)
+    Kernel.should_receive(:system).once.ordered.with(&quot;mencoder dvb://\&quot;2@CrudTV\&quot; -idx -oac copy -ovc copy -endpos 2100.0 -o \&quot;#{RAILS_ROOT}/public/recordings/Dora the Explorer/Dora the Explorer-2008-11-10-0730.avi\&quot; &gt;&gt; /tmp/pctv.log&quot;).and_return(false)
     Kernel.should_not_receive(:system).with(/ffmpeg/)
 
     oRecordEpisode.record( DateTime.new( 2008, 11, 10, 7, 30, 0))</diff>
      <filename>spec/lib/RecordEpisode_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>204aab6d500b4a0212b9acbddfa678df2ad580df</id>
    </parent>
  </parents>
  <author>
    <name>Peter Wilkinson</name>
    <email>peter.wilkinson@gmail.com</email>
  </author>
  <url>http://github.com/pinkblob/pctv/commit/704d14fe73ae22c28fc1e206e5c86ea2d58f9d0a</url>
  <id>704d14fe73ae22c28fc1e206e5c86ea2d58f9d0a</id>
  <committed-date>2009-03-13T10:08:40-07:00</committed-date>
  <authored-date>2009-03-13T10:08:40-07:00</authored-date>
  <message>* Add five minutes to recordings as peppa pig seems to start late
* Option to delete all recordings of a programme
* List of recordings by programme</message>
  <tree>05ae885b3d8b31f57cd5c5888abc96224e23908b</tree>
  <committer>
    <name>Peter Wilkinson</name>
    <email>peter.wilkinson@gmail.com</email>
  </committer>
</commit>
