tablo_connect 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/tablo_connect/ng_app/controllers/episodes_controller.js +1 -1
  3. data/app/assets/javascripts/tablo_connect/ng_app/controllers/movies_controller.js +1 -2
  4. data/app/assets/javascripts/tablo_connect/ng_app/controllers/shows_controller.js +1 -2
  5. data/app/assets/javascripts/tablo_connect/ng_app/filters/url_filter.js +24 -16
  6. data/app/assets/javascripts/tablo_connect/ng_app/services/tablo_service.js +6 -6
  7. data/app/assets/javascripts/tablo_connect/ng_app/templates/movies.html +1 -1
  8. data/app/assets/javascripts/tablo_connect/ng_app/templates/shows.html +1 -1
  9. data/app/controllers/tablo_connect/copy_controller.rb +2 -2
  10. data/app/controllers/tablo_connect/sync_controller.rb +23 -20
  11. data/app/models/tablo_connect/movie.rb +3 -2
  12. data/app/models/tablo_connect/show.rb +5 -5
  13. data/app/views/layouts/tablo_connect/application.html.erb +0 -4
  14. data/db/migrate/20151109173418_add_tablo_ip_to_tablo_connect_shows.rb +7 -0
  15. data/db/migrate/20151109173427_add_tablo_ip_to_tablo_connect_movies.rb +7 -0
  16. data/lib/tablo_connect.rb +2 -2
  17. data/lib/tablo_connect/engine.rb +2 -2
  18. data/lib/tablo_connect/version.rb +1 -1
  19. data/spec/controllers/tablo_connect/copy_controller_spec.rb +14 -14
  20. data/spec/controllers/tablo_connect/sync_controller_spec.rb +24 -24
  21. data/spec/factories/tablo_connect_movies.rb +1 -0
  22. data/spec/factories/tablo_connect_shows.rb +1 -1
  23. data/spec/javascript/angular-environment.js +0 -1
  24. data/spec/javascript/unit/controllers/movies_controller_spec.js +3 -9
  25. data/spec/javascript/unit/controllers/shows_controller_spec.js +3 -9
  26. data/spec/javascript/unit/filters/url_filter_spec.js +14 -0
  27. data/spec/javascript/unit/services/tablo_service_spec.js +2 -2
  28. data/spec/models/tablo_connect/movie_spec.rb +6 -2
  29. data/spec/models/tablo_connect/show_spec.rb +6 -2
  30. data/spec/test_app/db/schema.rb +5 -3
  31. data/spec/test_app/db/test.sqlite3 +0 -0
  32. data/spec/test_app/log/test.log +10416 -0
  33. metadata +4 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b024f7790404954ac14c778ac0fa9a3831ed8f17
4
- data.tar.gz: b90e132e3e0f0315721d14b52a869f4edb291134
3
+ metadata.gz: 31465bd7d2afd932a492da3cb6dcbceb60aaffda
4
+ data.tar.gz: e9c2fc111d540a9bcb2794e924ea8f89ec4401c0
5
5
  SHA512:
6
- metadata.gz: 2aff0b9c2e3590da31dce8801716da909068088af2c0ef07aec62d2632fe4c9784923fabbef5d7b51c3084197e9d64bbaba6cf2f46f1a71fc14beddd946cd184
7
- data.tar.gz: 2f6c2c7682dd16603f15a9ad10373c61378c106096307a01ad6c9126b8a25ecc0c9300a117b54af5ddc3473e58128b668bbb3f8424d9c7500042ccca9bc4a985
6
+ metadata.gz: 1257617683c66a08a877c42b65242755f4a269b13dda133230c478f38ead11b55815076b9d7f9bd0ac4a5fb39be5de530ab7359bb7f367dd1e03fc9e19c3f35b
7
+ data.tar.gz: 86febfc96596f98239c77dbf14236b2485874c27ada323b74355326a45f545a5a3c1082eae7841ce6d23190ab392bec554f5f8dafea155922ede93722f3077da
@@ -2,7 +2,7 @@
2
2
  'use strict';
3
3
 
4
4
  angular.module('ac.tabloConnectApp')
5
- .controller('EpisodesCtrl', ['$scope', '$stateParams', 'tabloBaseUrl', 'tabloService', 'alertsService', function ($scope, $stateParams, tabloBaseUrl, tabloService, alertsService) {
5
+ .controller('EpisodesCtrl', ['$scope', '$stateParams', 'tabloService', 'alertsService', function ($scope, $stateParams, tabloService, alertsService) {
6
6
  $scope.episodes = tabloService.episodeData();
7
7
  $scope.showTitle = $stateParams.showName;
8
8
  $scope.alerts = alertsService.getAlerts();
@@ -2,10 +2,9 @@
2
2
  'use strict';
3
3
 
4
4
  angular.module('ac.tabloConnectApp')
5
- .controller('MoviesCtrl', ['$scope', 'tabloService', 'tabloBaseUrl', 'alertsService', function ($scope, tabloService, tabloBaseUrl, alertsService) {
5
+ .controller('MoviesCtrl', ['$scope', 'tabloService', 'alertsService', function ($scope, tabloService, alertsService) {
6
6
  $scope.movies = tabloService.movieData();
7
7
  $scope.alerts = alertsService.getAlerts();
8
- $scope.tabloBaseUrl = tabloBaseUrl;
9
8
 
10
9
  $scope.copyRecording = function (movie) {
11
10
  alertsService.clearAlerts();
@@ -2,8 +2,7 @@
2
2
  'use strict';
3
3
 
4
4
  angular.module('ac.tabloConnectApp')
5
- .controller('ShowsCtrl', ['$scope', 'tabloBaseUrl', 'tabloService', function ($scope, tabloBaseUrl, tabloService) {
5
+ .controller('ShowsCtrl', ['$scope', 'tabloService', function ($scope, tabloService) {
6
6
  $scope.shows = tabloService.showData();
7
- $scope.tabloBaseUrl = tabloBaseUrl;
8
7
  }]);
9
8
  })(window.angular);
@@ -1,19 +1,27 @@
1
- (function(angular) {
2
- 'use strict';
1
+ (function (angular) {
2
+ 'use strict';
3
3
 
4
- angular.module('ac.url', [])
5
- .filter('urlencode', [function () {
6
- return function (string) {
7
- if (!!string) {
8
- return encodeURIComponent(string);
9
- }
10
- };
11
- }]).filter('urldecode', [function () {
12
- return function (string) {
13
- if (!!string) {
14
- return decodeURIComponent(string);
15
- }
16
- };
17
- }]);
4
+ angular.module('ac.url', [])
5
+ .filter('urlencode', [function () {
6
+ return function (string) {
7
+ if (!!string) {
8
+ return encodeURIComponent(string);
9
+ }
10
+ };
11
+ }])
12
+ .filter('urldecode', [function () {
13
+ return function (string) {
14
+ if (!!string) {
15
+ return decodeURIComponent(string);
16
+ }
17
+ };
18
+ }])
19
+ .filter('tabloBaseUrl', [function () {
20
+ return function (tabloIp) {
21
+ if (!!tabloIp) {
22
+ return 'http://' + tabloIp + ':18080';
23
+ }
24
+ };
25
+ }]);
18
26
 
19
27
  })(window.angular);
@@ -41,22 +41,22 @@
41
41
  episodeData: function() {
42
42
  return episodeData;
43
43
  },
44
- copyRecording: function (tabloId, type) {
44
+ copyRecording: function (recording, type) {
45
45
  return $http({
46
- url: '/tablo/copy/' + tabloId + '/' + type,
46
+ url: '/tablo/copy/' + recording.tablo_id + '/' + type + '?tablo_ip=' + recording.tablo_ip,
47
47
  method: 'GET'
48
48
  });
49
49
  },
50
- copyStatus: function (tabloId, type) {
50
+ copyStatus: function (recording, type) {
51
51
  return $http({
52
- url: '/tablo/copy/' + tabloId + '/' + type + '/status',
52
+ url: '/tablo/copy/' + recording.tablo_id + '/' + type + '/status?tablo_ip=' + recording.tablo_ip,
53
53
  method: 'GET'
54
54
  });
55
55
  },
56
56
  initCopy: function (recording, type) {
57
57
  var self = this;
58
58
 
59
- self.copyRecording(recording.tablo_id, type)
59
+ self.copyRecording(recording, type)
60
60
  .success(function () {
61
61
  recording.copy_status = 'in_progress';
62
62
  $timeout(function () {
@@ -70,7 +70,7 @@
70
70
  pollStatus: function (recording, type) {
71
71
  var self = this;
72
72
 
73
- self.copyStatus(recording.tablo_id, type)
73
+ self.copyStatus(recording, type)
74
74
  .success(function (res) {
75
75
  if (res.copy_status === 'in_progress') {
76
76
  $timeout(function () {
@@ -14,7 +14,7 @@
14
14
  </thead>
15
15
  <tbody>
16
16
  <tr ng-repeat="movie in movies track by $index">
17
- <td class="thumb"><img ng-src="{{tabloBaseUrl}}/stream/thumb?id={{movie.image_id}}"></td>
17
+ <td class="thumb"><img ng-src="{{movie.tablo_ip|tabloBaseUrl}}/stream/thumb?id={{movie.image_id}}"></td>
18
18
  <td ng-bind="movie.title"></td>
19
19
  <td ng-bind="movie.description"></td>
20
20
  <td ng-bind="movie.release_year"></td>
@@ -4,7 +4,7 @@
4
4
  <div ng-switch="!!shows">
5
5
  <div ng-switch-when="true">
6
6
  <a class="show-cell" ng-repeat="show in shows track by $index" ui-sref="episodes({showName: (show.show|urlencode)})">
7
- <img ng-src="{{tabloBaseUrl}}/stream/thumb?id={{show.image_id}}" alt="{{show.show}}">
7
+ <img ng-src="{{show.tablo_ip|tabloBaseUrl}}/stream/thumb?id={{show.image_id}}" alt="{{show.show}}">
8
8
  <div class="episode-count" ng-bind="show.count"></div>
9
9
  </a>
10
10
  </div>
@@ -29,12 +29,12 @@ module TabloConnect
29
29
  return head :not_found if @item.nil?
30
30
  end
31
31
 
32
- @item = model.find_by_tablo_id(params[:tablo_id])
32
+ @item = model.find_by_tablo_ip(params[:tablo_ip]).find_by_tablo_id(params[:tablo_id])
33
33
  head :not_found if @item.nil?
34
34
  end
35
35
 
36
36
  def source_path
37
- "#{TabloConnect.tablo_base_url}/pvr/#{@item.tablo_id}/pl/playlist.m3u8"
37
+ "#{TabloConnect.tablo_base_url(@item.tablo_ip)}/pvr/#{@item.tablo_id}/pl/playlist.m3u8"
38
38
  end
39
39
 
40
40
  def destination_path
@@ -5,9 +5,12 @@ module TabloConnect
5
5
  class SyncController < ApplicationController
6
6
  def index
7
7
  begin
8
- item_ids = parse_items
9
- delete_removed item_ids
10
- update_items(item_ids)
8
+ TabloConnect.tablo_ips.each do |ip|
9
+ item_ids = parse_items(ip)
10
+ delete_removed(ip, item_ids)
11
+ update_items(ip, item_ids)
12
+ end
13
+
11
14
  head :ok
12
15
  rescue => e
13
16
  render json: {error: e.to_s}, status: :internal_server_error
@@ -16,35 +19,35 @@ module TabloConnect
16
19
 
17
20
  private
18
21
 
19
- def parse_items
20
- page = Nokogiri::HTML(open("#{TabloConnect.tablo_base_url}/pvr/"))
22
+ def parse_items(tablo_ip)
23
+ page = Nokogiri::HTML(open("#{TabloConnect.tablo_base_url(tablo_ip)}/pvr/"))
21
24
  page.css('tbody a').map { |row|
22
25
  row[:href].gsub('/', '').to_i if row[:href].gsub('/', '') =~ /\A\d+\z/
23
26
  }.compact
24
27
  end
25
28
 
26
- def delete_removed(new_ids)
27
- old_ids = TabloConnect::Movie.select(:tablo_id).all + TabloConnect::Show.select(:tablo_id).all
28
- delete_ids = old_ids.map {|i| i.tablo_id } - new_ids
29
+ def delete_removed(tablo_ip, new_ids)
30
+ old_ids = TabloConnect::Movie.find_by_tablo_ip(tablo_ip) + TabloConnect::Show.find_by_tablo_ip(tablo_ip)
31
+ delete_ids = old_ids.map { |i| i.tablo_id } - new_ids
29
32
 
30
- TabloConnect::Movie.delete_by_tablo_id(delete_ids)
31
- TabloConnect::Show.delete_by_tablo_id(delete_ids)
33
+ TabloConnect::Movie.find_by_tablo_ip(tablo_ip).delete_by_tablo_id(delete_ids)
34
+ TabloConnect::Show.find_by_tablo_ip(tablo_ip).delete_by_tablo_id(delete_ids)
32
35
  end
33
36
 
34
- def update_items(tablo_ids)
37
+ def update_items(tablo_ip, tablo_ids)
35
38
  tablo_ids.each do |tablo_id|
36
- details = recording_details tablo_id
39
+ details = recording_details(tablo_ip, tablo_id)
37
40
 
38
41
  if details[:recMovie].present?
39
- update_movie(tablo_id, details)
42
+ update_movie(tablo_ip, tablo_id, details)
40
43
  elsif details[:recEpisode].present?
41
- update_show(tablo_id, details)
44
+ update_show(tablo_ip, tablo_id, details)
42
45
  end
43
46
  end
44
47
  end
45
48
 
46
- def update_movie(tablo_id, details)
47
- item = TabloConnect::Movie.find_or_create_by(tablo_id: tablo_id)
49
+ def update_movie(tablo_ip, tablo_id, details)
50
+ item = TabloConnect::Movie.find_or_create_by(tablo_ip: tablo_ip, tablo_id: tablo_id)
48
51
  item.title = details.try(:[], :recMovie).try(:[], :jsonForClient).try(:[], :title)
49
52
  item.description = details.try(:[], :recMovie).try(:[], :jsonForClient).try(:[], :plot)
50
53
  item.release_year = details.try(:[], :recMovie).try(:[], :jsonForClient).try(:[], :releaseYear)
@@ -53,8 +56,8 @@ module TabloConnect
53
56
  item.save!
54
57
  end
55
58
 
56
- def update_show(tablo_id, details)
57
- item = TabloConnect::Show.find_or_create_by(tablo_id: tablo_id)
59
+ def update_show(tablo_ip, tablo_id, details)
60
+ item = TabloConnect::Show.find_or_create_by(tablo_ip: tablo_ip, tablo_id: tablo_id)
58
61
  item.show = details.try(:[], :recEpisode).try(:[], :jsonFromTribune).try(:[], :program).try(:[], :title)
59
62
  item.title = details.try(:[], :recEpisode).try(:[], :jsonFromTribune).try(:[], :program).try(:[], :episodeTitle)
60
63
  item.description = details.try(:[], :recEpisode).try(:[], :jsonFromTribune).try(:[], :program).try(:[], :longDescription)
@@ -66,8 +69,8 @@ module TabloConnect
66
69
  item.save!
67
70
  end
68
71
 
69
- def recording_details(tablo_id)
70
- JSON.parse(RestClient.get("#{TabloConnect.tablo_base_url}/pvr/#{tablo_id}/meta.txt")).with_indifferent_access
72
+ def recording_details(tablo_ip, tablo_id)
73
+ JSON.parse(RestClient.get("#{TabloConnect.tablo_base_url(tablo_ip)}/pvr/#{tablo_id}/meta.txt")).with_indifferent_access
71
74
  end
72
75
  end
73
76
  end
@@ -1,11 +1,12 @@
1
1
  module TabloConnect
2
2
  class Movie < ActiveRecord::Base
3
- validates_presence_of :tablo_id
4
- validates_uniqueness_of :tablo_id
3
+ validates_presence_of :tablo_ip, :tablo_id
4
+ validates_uniqueness_of :tablo_ip, scope: :tablo_id
5
5
 
6
6
  enum copy_status: [:idle, :in_progress, :complete]
7
7
 
8
8
  scope :all_order_title, -> { self.all.order(:title) }
9
+ scope :find_by_tablo_ip, -> (tablo_ip) { where(tablo_ip: tablo_ip) }
9
10
 
10
11
  def self.delete_by_tablo_id(delete_ids)
11
12
  self.where(tablo_id: delete_ids).delete_all
@@ -1,18 +1,18 @@
1
1
  module TabloConnect
2
2
  class Show < ActiveRecord::Base
3
- validates_presence_of :tablo_id
4
- validates_uniqueness_of :tablo_id
3
+ validates_presence_of :tablo_ip, :tablo_id
4
+ validates_uniqueness_of :tablo_ip, scope: :tablo_id
5
5
 
6
6
  enum copy_status: [:idle, :in_progress, :complete]
7
7
 
8
8
  scope :shows, -> { group(:show).order(:show).count }
9
9
  scope :show_episodes, ->(show) { where(show: show).order(:season, :episode, :rec_date, :title) }
10
+ scope :find_by_tablo_ip, -> (tablo_ip) { where(tablo_ip: tablo_ip) }
10
11
 
11
12
  def self.shows_with_image_id
12
13
  self.shows.map { |show|
13
- image_id = self.select(:image_id).distinct(:image_id).where({show: show[0]}).order(image_id: :desc).limit(1)[0].try(:[], :image_id)
14
-
15
- {show: show[0], count: show[1], image_id: image_id}
14
+ image_data = self.select(:image_id, :tablo_ip).distinct(:image_id).where({show: show[0]}).order(image_id: :desc).limit(1).first
15
+ {show: show[0], count: show[1], image_id: image_data.try(:[], :image_id), tablo_ip: image_data.try(:[], :tablo_ip)}
16
16
  }
17
17
  end
18
18
 
@@ -10,10 +10,6 @@
10
10
  <div class="container-fluid">
11
11
  <%= yield %>
12
12
  </div>
13
-
14
13
  <%= javascript_include_tag "tablo_connect/application" %>
15
- <script>
16
- angular.module('ac.tabloConnectApp').constant('tabloBaseUrl', '<%= "http://#{TabloConnect.tablo_ip}:#{TabloConnect.tablo_port}" %>')
17
- </script>
18
14
  </body>
19
15
  </html>
@@ -0,0 +1,7 @@
1
+ class AddTabloIpToTabloConnectShows < ActiveRecord::Migration
2
+ def change
3
+ add_column :tablo_connect_shows, :tablo_ip, :string
4
+ remove_index :tablo_connect_shows, :tablo_id
5
+ add_index :tablo_connect_shows, [:tablo_ip, :tablo_id], :unique => true
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class AddTabloIpToTabloConnectMovies < ActiveRecord::Migration
2
+ def change
3
+ add_column :tablo_connect_movies, :tablo_ip, :string
4
+ remove_index :tablo_connect_movies, :tablo_id
5
+ add_index :tablo_connect_movies, [:tablo_ip, :tablo_id], :unique => true
6
+ end
7
+ end
@@ -1,7 +1,7 @@
1
1
  require "tablo_connect/engine"
2
2
 
3
3
  module TabloConnect
4
- def self.tablo_base_url
5
- "http://#{TabloConnect.tablo_ip}:#{TabloConnect.tablo_port}"
4
+ def self.tablo_base_url(tablo_ip)
5
+ "http://#{tablo_ip}:#{TabloConnect.tablo_port}"
6
6
  end
7
7
  end
@@ -9,8 +9,8 @@ module TabloConnect
9
9
  end
10
10
 
11
11
  class << self
12
- mattr_accessor :tablo_ip
13
- self.tablo_ip = '192.168.1.99'
12
+ mattr_accessor :tablo_ips
13
+ self.tablo_ips = ['127.0.0.1']
14
14
 
15
15
  mattr_accessor :tablo_port
16
16
  self.tablo_port = '180809'
@@ -1,3 +1,3 @@
1
1
  module TabloConnect
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -15,32 +15,32 @@ module TabloConnect
15
15
 
16
16
  context "when the item is not found" do
17
17
  it "returns a 404" do
18
- get :index, {tablo_id: 99999, type: 'some_type'}
18
+ get :index, {tablo_ip: show.tablo_ip, tablo_id: 99999, type: 'some_type'}
19
19
  expect(response.status).to eq 404
20
20
  end
21
21
  end
22
22
 
23
23
  context "when the item is found" do
24
24
  it "returns a 200" do
25
- get :index, {tablo_id: show.tablo_id, type: 'show'}
25
+ get :index, {tablo_ip: TabloConnect.tablo_ips[0], tablo_id: show.tablo_id, type: 'show'}
26
26
  expect(response.status).to eq 200
27
27
  end
28
28
 
29
29
  it "calls spawn" do
30
30
  expect(controller).to receive(:spawn)
31
- get :index, {tablo_id: show.tablo_id, type: 'show'}
31
+ get :index, {tablo_ip: TabloConnect.tablo_ips[0], tablo_id: show.tablo_id, type: 'show'}
32
32
  end
33
33
 
34
34
  it "sets the copy_status to in_progress" do
35
35
  item = TabloConnect::Show.find_by_tablo_id show.tablo_id
36
36
  expect(item.copy_status).to eq('idle')
37
- get :index, {tablo_id: show.tablo_id, type: 'show'}
37
+ get :index, {tablo_ip: TabloConnect.tablo_ips[0], tablo_id: show.tablo_id, type: 'show'}
38
38
  item.reload
39
39
  expect(item.copy_status).to eq('in_progress')
40
40
  end
41
41
 
42
42
  it "returns an object with a shows array" do
43
- get :index, {tablo_id: show.tablo_id, type: 'show'}
43
+ get :index, {tablo_ip: TabloConnect.tablo_ips[0], tablo_id: show.tablo_id, type: 'show'}
44
44
  json_body = JSON.parse(response.body).with_indifferent_access
45
45
  expect(json_body).to match({pid: 1234, destination: '/tmp/output.mp4'})
46
46
  end
@@ -50,16 +50,16 @@ module TabloConnect
50
50
  describe "GET status" do
51
51
  it "calls file_copy_status" do
52
52
  expect(controller).to receive(:file_copy_status)
53
- get :status, {tablo_id: show.tablo_id, type: 'show'}
53
+ get :status, {tablo_ip: TabloConnect.tablo_ips[0], tablo_id: show.tablo_id, type: 'show'}
54
54
  end
55
55
 
56
56
  it "returns a 200 status code" do
57
- get :status, {tablo_id: show.tablo_id, type: 'show'}
57
+ get :status, {tablo_ip: TabloConnect.tablo_ips[0], tablo_id: show.tablo_id, type: 'show'}
58
58
  expect(response.status).to eq 200
59
59
  end
60
60
 
61
61
  it "returns a JSON object with the copy_status" do
62
- get :status, {tablo_id: show.tablo_id, type: 'show'}
62
+ get :status, {tablo_ip: TabloConnect.tablo_ips[0], tablo_id: show.tablo_id, type: 'show'}
63
63
  json_body = JSON.parse(response.body).with_indifferent_access
64
64
  expect(json_body[:copy_status]).to eq show.copy_status
65
65
  end
@@ -72,7 +72,7 @@ module TabloConnect
72
72
 
73
73
  context "when the type is not show or movie" do
74
74
  it "returns a 404" do
75
- allow(controller).to receive(:params).and_return({tablo_id: show.tablo_id, type: 'invalid_type'})
75
+ allow(controller).to receive(:params).and_return({tablo_ip: TabloConnect.tablo_ips[0], tablo_id: show.tablo_id, type: 'invalid_type'})
76
76
  expect(controller).to receive(:head).with(:not_found)
77
77
  controller.send(:set_item)
78
78
  end
@@ -81,7 +81,7 @@ module TabloConnect
81
81
  context "when the type is 'show' or 'movie'" do
82
82
  context "when the type is 'movie'" do
83
83
  it "uses the Movie model" do
84
- allow(controller).to receive(:params).and_return({tablo_id: show.tablo_id, type: 'movie'})
84
+ allow(controller).to receive(:params).and_return({tablo_ip: show.tablo_ip, tablo_id: show.tablo_id, type: 'movie'})
85
85
  expect(TabloConnect::Movie).to receive(:find_by_tablo_id).with(show.tablo_id)
86
86
  controller.send(:set_item)
87
87
  end
@@ -89,7 +89,7 @@ module TabloConnect
89
89
 
90
90
  context "when the type is 'show'" do
91
91
  it "uses the Show model" do
92
- allow(controller).to receive(:params).and_return({tablo_id: show.tablo_id, type: 'show'})
92
+ allow(controller).to receive(:params).and_return({tablo_ip: show.tablo_ip, tablo_id: show.tablo_id, type: 'show'})
93
93
  expect(TabloConnect::Show).to receive(:find_by_tablo_id).with(show.tablo_id)
94
94
  controller.send(:set_item)
95
95
  end
@@ -97,14 +97,14 @@ module TabloConnect
97
97
 
98
98
  context "when the item is not found" do
99
99
  it "returns a 404" do
100
- allow(controller).to receive(:params).and_return({tablo_id: 99999, type: 'show'})
100
+ allow(controller).to receive(:params).and_return({tablo_ip: show.tablo_ip, tablo_id: 99999, type: 'show'})
101
101
  controller.send(:set_item)
102
102
  end
103
103
  end
104
104
 
105
105
  context "when the item is found" do
106
106
  it "sets the @item instance variable" do
107
- allow(controller).to receive(:params).and_return({tablo_id: show.tablo_id, type: 'show'})
107
+ allow(controller).to receive(:params).and_return({tablo_ip: show.tablo_ip, tablo_id: show.tablo_id, type: 'show'})
108
108
  controller.send(:set_item)
109
109
  item = controller.instance_variable_get(:@item)
110
110
  expect(item).to match(show)
@@ -117,7 +117,7 @@ module TabloConnect
117
117
  it "builds the source_path with the tablo_id" do
118
118
  controller.instance_variable_set(:@item, show)
119
119
  path = controller.send(:source_path)
120
- expect(path).to eq "#{TabloConnect.tablo_base_url}/pvr/#{show.tablo_id}/pl/playlist.m3u8"
120
+ expect(path).to eq "#{TabloConnect.tablo_base_url(show.tablo_ip)}/pvr/#{show.tablo_id}/pl/playlist.m3u8"
121
121
  end
122
122
  end
123
123