nickludlam-ruby-mythtv 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,12 @@
1
+ == 0.2.0 (2008-09-29)
2
+
3
+ * Bumped to version 0.2 as we now support proper editing of recording schedules, and speaking multiple versions of the database schema
4
+
5
+ == 0.1.2 (2008-09-24)
6
+
7
+ * Added support for talking to the MythTV MySQL database, to allow queries on the EPG, and interacting with recording schedules
8
+ * Removed the XML program guide as it is superceded by the database
9
+
1
10
  == 0.1.1 (2008-07-27)
2
11
 
3
12
  * Updated documentation
data/README.txt CHANGED
@@ -1,18 +1,24 @@
1
- = Ruby-mythtv
1
+ = ruby-mythtv
2
2
 
3
3
  == Description
4
4
 
5
- A pure Ruby implementation of the MythTV Backend protocol to allow interaction with a MythTV server. Features include browsing and streaming of recordings, and thumbnail generation. See http://github.com/nickludlam/ruby-mythtv for more details.
5
+ A pure Ruby implementation of the MythTV Backend protocol, and a MySQL database wrapper to allow interaction with a MythTV server. Features include browsing and streaming of recordings, thumbnail generation, listing channels and programs, and recording schedule editing. Currently the most complicated use of the gem is from the tests in the test/ subdirectory. See http://github.com/nickludlam/ruby-mythtv for more details.
6
6
 
7
7
  == Requirements
8
8
 
9
- This gem does not yet support multiple protocol versions, so it requires an up-to-date installation of MythTV v0.21, and specifically implements protocol version 40. For more information on the history of the MythTV protocol, see http://www.mythtv.org/wiki/index.php/Protocol
9
+ This gem relies on the 'mysql' gem, and obviously requires a MythTV server to talk to. The Gem is version independent, and currently knows how to speak the backend protocol versions 31 and 40. It can also cope with different versions of the MySQL database schema.
10
10
 
11
11
  == Install
12
12
 
13
+ To install from RubyForge:
14
+
15
+ $ gem install ruby-mythtv
16
+
17
+ To install from GitHub:
18
+
13
19
  $ gem sources -a http://gems.github.com/ (only required once)
14
20
  $ gem install nickludlam-ruby-mythtv
15
-
21
+
16
22
  == Source
17
23
 
18
24
  The ruby-mythtv source is available on GitHub at
@@ -25,10 +31,13 @@ and can be cloned from
25
31
 
26
32
  == Basic usage
27
33
 
34
+ If you want to enumerate the current recordings, select one and stream it to disk, then it would
35
+ look something like this.
36
+
28
37
  require 'ruby-mythtv'
29
38
 
30
39
  # Connect to the server
31
- mythbackend, mythdb = MythTV.connect(:host => 'mythtv.localdomain')
40
+ mythbackend = MythTV.connect_backend(:host => 'mythtv.localdomain')
32
41
 
33
42
  # Get an array of recordings
34
43
  recordings = mythbackend.query_recordings
@@ -45,6 +54,38 @@ and can be cloned from
45
54
  preview_thumbnail = mythbackend.preview_image(recordings[0], :secs_in => 60)
46
55
  File.open('preview_thumbnail.png', 'w') { |f| f.write(preview_thumbnail) }
47
56
 
57
+ == Advanced usage
58
+
59
+ If you wanted to search for a particular program name, and set up a schedule
60
+
61
+ require 'ruby-mythtv'
62
+
63
+ # Connect to the server
64
+ mythbackend, mythdb = MythTV.connect(:host => 'mythtv.localdomain',
65
+ :database_password => 'password')
66
+
67
+ # Find matches on our search term, and limit the results to 5 matches
68
+ programs = mythdb.list_programs(:conditions => ['title LIKE ?', "%SEARCH TERM%"],
69
+ :limit => 5)
70
+
71
+ # Take the first program match, and convert it to a recording schedule
72
+ new_schedule = MythTV::RecordingSchedule.new(programs[0], mythdb)
73
+ new_schedule.save
74
+
75
+ # Signal the backend of recording changes for our recording schedule entry
76
+ mythbackend.reschedule_recordings(new_schedule.recordid)
77
+
78
+ # Let the backend resolve matches
79
+ sleep(5)
80
+
81
+ # Enumerate the list of pending recordings, find ours, and check for any conflicts
82
+ pending_recordings = mythbackend.query_pending
83
+ conflicts = pending_recordings.find { |p| p.recordid == new_schedule.recordid &&
84
+ p.recstatus_sym == :rsConflict }
85
+
86
+ # If conflicts is empty, then all is good. If it is populated, then action needs
87
+ # to be taken, such as bumping the priority, or removing the clashes....
88
+
48
89
  == Author
49
90
 
50
91
  Written in 2008 by Nick Ludlam <nick@recoil.org>
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/testtask'
5
5
 
6
6
  spec = Gem::Specification.new do |s|
7
7
  s.name = %q{ruby-mythtv}
8
- s.version = "0.1.2"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.specification_version = 2 if s.respond_to? :specification_version=
11
11
 
@@ -21,7 +21,7 @@ spec = Gem::Specification.new do |s|
21
21
  s.rdoc_options = ["--main", "README.txt"]
22
22
  s.require_paths = ["lib"]
23
23
  s.rubyforge_project = %q{ruby-mythtv}
24
- s.rubygems_version = %q{0.1.2}
24
+ s.rubygems_version = %q{0.2.0}
25
25
  s.summary = %q{Ruby implementation of the MythTV backend protocol}
26
26
  s.test_files = ["test/test_backend.rb", "test/test_helper.rb"]
27
27
  end
data/Todo.txt CHANGED
@@ -2,4 +2,5 @@
2
2
  - Look at how we obtain the channel icon by streaming a backend file (see existing MythTV Perl module)
3
3
  - Support Ruby 1.9
4
4
  - Support seeking with the MythTV::Backend#stream() method
5
- - Work out method to remove and add database columns for Channel/Program/RecordingSchedule, as we do for the PROTOCOL mapping system. It seems the database can change without the Protocol version being bumped, so they are independent.
5
+ - Look at how we need to pass the DB instance to each constructor for Channel, Program and RecordingSchedule. Automate the link back to db instance?
6
+ - Make use of the ENUMS placed in RecordingSchedule to help with validation of various columns
data/lib/ruby-mythtv.rb CHANGED
@@ -21,7 +21,7 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module MythTV
24
- VERSION = '0.1.2'
24
+ VERSION = '0.2.0'
25
25
 
26
26
  def self.connect(options)
27
27
  backend = connect_backend(options)
data/test/test_db.rb CHANGED
@@ -3,10 +3,10 @@ require File.dirname(__FILE__) + '/test_helper.rb'
3
3
  class TestDatabase < Test::Unit::TestCase
4
4
  def setup
5
5
  abort("\n\tmyERROR: You must set the environment variable MYTHTV_DB to the name of your MythTV database server\n\n") unless ENV['MYTHTV_DB']
6
+ abort("\n\tmyERROR: You must set the environment variable MYTHTV_PW to the name of your MythTV database server\n\n") unless ENV['MYTHTV_PW']
6
7
  @db = MythTV.connect_database(:host => ENV['MYTHTV_DB'],
7
- :database_user => 'mythtv',
8
- :database_password => '4c6UUCJp',
9
- :log_level => Logger::WARN)
8
+ :database_password => ENV['MYTHTV_PW'],
9
+ :log_level => Logger::DEBUG)
10
10
  end
11
11
 
12
12
  def teardown
@@ -102,7 +102,32 @@ class TestDatabase < Test::Unit::TestCase
102
102
 
103
103
  assert new_schedule.recordid > 0
104
104
 
105
- assert new_schedule.destroy()
105
+ destroy_result = new_schedule.destroy()
106
+ assert destroy_result
107
+ end
108
+
109
+ def test_new_and_modify_schedule
110
+ # Get list of schedules for later reference
111
+ num_schedules = @db.list_recording_schedules
112
+ programs = @db.list_programs(:conditions => ['starttime BETWEEN ? AND ?', Time.now + 3600, Time.now + 7200],
113
+ :limit => 1)
114
+
115
+ # Convert our first program selected into a recording schedule
116
+ new_schedule = MythTV::RecordingSchedule.new(programs[0], @db)
117
+ new_schedule.save
118
+
119
+ new_schedule.type = 4
120
+ new_schedule.save
121
+
122
+ test_query = @db.list_recording_schedules(:conditions => ['recordid = ?', new_schedule.recordid])
123
+ assert_equal 1, test_query.length
124
+
125
+ test_retrieval = test_query[0]
126
+
127
+ assert_equal 4, test_retrieval.type
128
+
129
+ destroy_result = new_schedule.destroy()
130
+ assert destroy_result
106
131
  end
107
132
 
108
133
  end
data/test/test_helper.rb CHANGED
@@ -1,2 +1,3 @@
1
1
  require 'test/unit'
2
+ require 'logger'
2
3
  require File.dirname(__FILE__) + '/../lib/ruby-mythtv'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nickludlam-ruby-mythtv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Ludlam
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-24 00:00:00 -07:00
12
+ date: 2008-09-29 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency