iplayer-dl 0.1.17 → 0.1.18

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.
Binary file
@@ -43,20 +43,35 @@ class Browser
43
43
  @http_class = http_class
44
44
  end
45
45
 
46
+ def post(location, data, headers={}, &blk)
47
+ request(:post, location, data, headers, &blk)
48
+ end
49
+
46
50
  def get(location, headers={}, &blk)
51
+ request(:get, location, nil, headers, &blk)
52
+ end
53
+
54
+ def request(type, location, data, headers, &blk)
47
55
  url = URI.parse(location)
48
56
  http = @http_class.new(url.host, url.port)
49
57
  path = url.path
50
58
  if url.query
51
59
  path << '?' << url.query
52
60
  end
61
+ headers_to_send = DEFAULT_HEADERS.merge(headers)
53
62
  if defined? DEBUG
54
63
  puts path
55
- DEFAULT_HEADERS.merge(headers).each do |k,v|
64
+ headers_to_send.each do |k,v|
56
65
  puts " -> #{k}: #{v}"
57
66
  end
58
67
  end
59
- response = http.request_get(path, DEFAULT_HEADERS.merge(headers), &blk)
68
+ response =
69
+ case type
70
+ when :get
71
+ http.request_get(path, headers_to_send, &blk)
72
+ when :post
73
+ http.request_post(path, data, headers_to_send, &blk)
74
+ end
60
75
  if defined? DEBUG
61
76
  response.each do |k,v|
62
77
  puts "<- #{k}: #{v}"
@@ -3,7 +3,6 @@ require 'cgi'
3
3
  module IPlayer
4
4
  class Downloader
5
5
 
6
- IPHONE_URL = 'http://www.bbc.co.uk/mobile/iplayer/'
7
6
  EPISODE_URL = 'http://www.bbc.co.uk/mobile/iplayer/episode/%s'
8
7
  SELECTOR_URL = 'http://www.bbc.co.uk/mediaselector/3/auth/iplayer_streaming_http_mp4/%s?%s'
9
8
  MAX_SEGMENT = 4 * 1024 * 1024
@@ -41,7 +40,17 @@ class Downloader
41
40
  def get(url, user_agent, options={}, &blk)
42
41
  options['User-Agent'] = user_agent
43
42
  options['Cookie'] = cookies if cookies
44
- browser.get(url, options, &blk)
43
+ response = browser.get(url, options, &blk)
44
+ self.cookies = response.cookies.join('; ')
45
+ response
46
+ end
47
+
48
+ def post(url, data, user_agent, options={}, &blk)
49
+ options['User-Agent'] = user_agent
50
+ options['Cookie'] = cookies if cookies
51
+ response = browser.post(url, data, options, &blk)
52
+ self.cookies = response.cookies.join('; ')
53
+ response
45
54
  end
46
55
 
47
56
  def available_versions
@@ -79,22 +88,20 @@ class Downloader
79
88
 
80
89
  private
81
90
 
82
- def request_iphone_page
83
- response = get(IPHONE_URL, Browser::IPHONE_UA)
84
- raise ProgrammeDoesNotExist unless response.is_a?(Net::HTTPSuccess)
85
- self.cookies = response.cookies.join('; ')
86
- end
87
-
88
91
  def request_episode_page(pid)
89
92
  response = get(EPISODE_URL % pid, Browser::IPHONE_UA)
90
93
  raise ProgrammeDoesNotExist unless response.is_a?(Net::HTTPSuccess)
94
+ if response.body =~ /isOver\d+/
95
+ data = "form=guidanceprompt&#$&=1"
96
+ response = post(EPISODE_URL % pid, data, Browser::IPHONE_UA)
97
+ raise ProgrammeDoesNotExist unless response.is_a?(Net::HTTPSuccess)
98
+ end
91
99
  response.body
92
100
  end
93
101
 
94
102
  def real_stream_location(pid)
95
- request_iphone_page
96
103
  html = request_episode_page(pid)
97
- location = html[%r{http://download\.iplayer\.bbc\.co\.uk/iplayer_streaming[^"']+}]
104
+ location = html[%r{<embed[^>]*?href="(http://[^"]+)}, 1]
98
105
 
99
106
  unless location
100
107
  raise FileUnavailable
@@ -6,9 +6,9 @@ module Translations
6
6
  :download_button => "Download ...",
7
7
  :about_button => "About ...",
8
8
  :status_waiting => "Waiting",
9
+ :status_stopped => "Stopped",
9
10
  :pid_tool_tip => "Use either the short alphanumeric programme identifier or "+
10
11
  "the URL of the viewing page on the iPlayer website.",
11
- :status_waiting => "Waiting",
12
12
  :no_pid_given => "You must specify a programme ID before I can download it.",
13
13
  :save_dialog_title => "Save As",
14
14
  :file_types => "iPlayer programmes",
@@ -52,6 +52,8 @@ module Translations
52
52
  [self.class.get_translation_namespace, key.to_s].flatten.compact.join(".").split(".").inject(STRINGS){ |hash, subkey|
53
53
  hash[subkey.to_sym]
54
54
  }.gsub(/\{\{([^\}]+)\}\}/){ methods[$1.to_sym] }
55
+ rescue
56
+ "MISSING TRANSLATION: #{key}"
55
57
  end
56
58
 
57
59
  def self.included(klass)
@@ -1,4 +1,4 @@
1
1
  module IPlayer
2
- VERSION = '0.1.17'
3
- GUI_VERSION = '1.13'
2
+ VERSION = '0.1.18'
3
+ GUI_VERSION = '1.14'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iplayer-dl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.17
4
+ version: 0.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Battley
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-16 00:00:00 +00:00
12
+ date: 2009-12-19 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -35,29 +35,33 @@ files:
35
35
  - README
36
36
  - setup.rb
37
37
  - Rakefile
38
- - lib/iplayer.rb
38
+ - lib/iplayer/.version.rb.swp
39
39
  - lib/iplayer/version.rb
40
- - lib/iplayer/translations.rb
41
- - lib/iplayer/subtitles.rb
40
+ - lib/iplayer/browser.rb
41
+ - lib/iplayer/downloader.rb
42
42
  - lib/iplayer/preferences.rb
43
- - lib/iplayer/metadata.rb
44
- - lib/iplayer/gui/main_frame.rb
45
43
  - lib/iplayer/gui/frame.rb
46
44
  - lib/iplayer/gui/app.rb
45
+ - lib/iplayer/gui/main_frame.rb
46
+ - lib/iplayer/subtitles.rb
47
47
  - lib/iplayer/errors.rb
48
- - lib/iplayer/downloader.rb
48
+ - lib/iplayer/.browser.rb.swp
49
+ - lib/iplayer/.downloader.rb.swp
50
+ - lib/iplayer/translations.rb
51
+ - lib/iplayer/metadata.rb
49
52
  - lib/iplayer/constants.rb
50
- - lib/iplayer/browser.rb
51
- - test/test_subtitles.rb
53
+ - lib/iplayer.rb
52
54
  - test/test_preferences.rb
53
55
  - test/test_metadata.rb
54
- - bin/iplayer-dl-gui
56
+ - test/test_subtitles.rb
55
57
  - bin/iplayer-dl
56
- - share/pixmaps/iplayer-dl/icon64.png
58
+ - bin/iplayer-dl-gui
59
+ - bin/.iplayer-dl.swp
60
+ - share/pixmaps/iplayer-dl/icon128.png
57
61
  - share/pixmaps/iplayer-dl/icon48.png
58
- - share/pixmaps/iplayer-dl/icon32.png
59
62
  - share/pixmaps/iplayer-dl/icon16.png
60
- - share/pixmaps/iplayer-dl/icon128.png
63
+ - share/pixmaps/iplayer-dl/icon32.png
64
+ - share/pixmaps/iplayer-dl/icon64.png
61
65
  has_rdoc: true
62
66
  homepage: http://po-ru.com/projects/iplayer-downloader
63
67
  licenses: []