railscasts_download 0.2.2 → 0.3.0
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.
- data/README.md +9 -2
- data/bin/railscasts_download +19 -8
- data/lib/railscasts_download/page_explorer.rb +1 -1
- data/lib/railscasts_download/rss_explorer.rb +4 -2
- data/lib/railscasts_download/saver.rb +4 -3
- data/lib/railscasts_download/version.rb +1 -1
- data/test/functional/rss_explorer_test.rb +6 -1
- data/test/stubs/rss_explorer.rb +1 -1
- metadata +7 -7
data/README.md
CHANGED
@@ -8,18 +8,25 @@ Downloader use Railscasts rss feed to get list of all videos. Automatic download
|
|
8
8
|
|
9
9
|
All railscasts including revised and pro (pro account required):
|
10
10
|
|
11
|
-
railscasts_download --
|
11
|
+
railscasts_download --pro -login my_login@railscasts.com
|
12
12
|
> Enter your password: *********
|
13
13
|
|
14
14
|
custom railscasts list:
|
15
15
|
|
16
16
|
railscasts_download --rss_uri /home/yourname/custom_railscasts_list.rss
|
17
17
|
|
18
|
+
|
18
19
|
or simply put:
|
19
20
|
|
20
21
|
railscasts_download
|
21
22
|
|
22
|
-
to get
|
23
|
+
to get all free railscasts.
|
24
|
+
You can also download only latest railscasts providing option --after.
|
25
|
+
Put:
|
26
|
+
|
27
|
+
railscasts_download --help
|
28
|
+
|
29
|
+
to get available options list.
|
23
30
|
|
24
31
|
## Installation
|
25
32
|
|
data/bin/railscasts_download
CHANGED
@@ -10,17 +10,23 @@ optparse = OptionParser.new do|opts|
|
|
10
10
|
opts.banner = "Usage: railscasts_download [options][--revised --login LOGIN --password PASSWORD]"
|
11
11
|
|
12
12
|
options[:rss_uri] = false
|
13
|
-
opts.on( '-
|
13
|
+
opts.on( '-r', '--rss_uri RSS_URI', 'Get file specified by URI as videos list source.
|
14
|
+
This could be a remote url or local file system path.' ) do |rss_uri|
|
14
15
|
options[:rss_uri] = rss_uri
|
15
16
|
end
|
16
17
|
|
17
|
-
options[:
|
18
|
-
opts.on( '-
|
19
|
-
options[:
|
18
|
+
options[:after] = false
|
19
|
+
opts.on( '-a', '--after YYYY-MM-DD', 'Get only files published after entered date.' ) do |date|
|
20
|
+
options[:after] = date
|
21
|
+
end
|
22
|
+
|
23
|
+
options[:pro] = false
|
24
|
+
opts.on( '-p', '--pro', 'Get all railscasts with revised and pro (login to pro account required).' ) do
|
25
|
+
options[:pro] = true
|
20
26
|
end
|
21
27
|
|
22
28
|
options[:login_uri] = false
|
23
|
-
opts.on( '-
|
29
|
+
opts.on( '-u', '--login_uri LOGIN_URI', 'Specify Login URI (required if it`s has been changed`).' ) do |login_uri|
|
24
30
|
options[:login_uri] = login_uri
|
25
31
|
end
|
26
32
|
|
@@ -29,16 +35,21 @@ optparse = OptionParser.new do|opts|
|
|
29
35
|
options[:login] = login
|
30
36
|
end
|
31
37
|
|
38
|
+
opts.on( '-v','--version', 'Display version info' ) do
|
39
|
+
puts "#{RailscastsDownload::VERSION}"
|
40
|
+
exit!
|
41
|
+
end
|
42
|
+
|
32
43
|
opts.on( '-h', '--help', 'Display this screen' ) do
|
33
44
|
puts opts
|
34
|
-
puts "
|
45
|
+
puts "\nReleased under the MIT license. Copyright (C) 2012 Karol Nowicki"
|
35
46
|
exit
|
36
47
|
end
|
48
|
+
|
37
49
|
end
|
38
50
|
|
39
51
|
optparse.parse!
|
40
52
|
|
41
|
-
options[:password] = ask("Enter your password: ") { |q| q.echo = "*" } if options[:
|
42
|
-
|
53
|
+
options[:password] = ask("Enter your password: ") { |q| q.echo = "*" } if options[:pro]
|
43
54
|
saver = RailscastsDownload::Saver.new( options )
|
44
55
|
saver.get_all
|
@@ -1,14 +1,16 @@
|
|
1
1
|
module RailscastsDownload
|
2
2
|
class RssExplorer
|
3
3
|
require 'rss'
|
4
|
+
require 'date'
|
4
5
|
|
5
6
|
def initialize( rss_body )
|
6
7
|
@body = rss_body
|
7
8
|
get_rss
|
8
9
|
end
|
9
10
|
|
10
|
-
def get_uris
|
11
|
-
@
|
11
|
+
def get_uris( options = {} )
|
12
|
+
@after = Date.parse( options[:after] || '2000-01-01' )
|
13
|
+
@rss.items.reject{ |it| it.pubDate.to_date < @after }.map{ |it| it.enclosure.url }.reverse
|
12
14
|
end
|
13
15
|
|
14
16
|
private
|
@@ -6,10 +6,11 @@ module RailscastsDownload
|
|
6
6
|
class Saver
|
7
7
|
def initialize( options={} )
|
8
8
|
@downloader = options[:downloader] || Downloader.new
|
9
|
-
options[:rss_uri] ||= "http://feeds.feedburner.com/railscasts" unless options[:
|
10
|
-
options[:login_uri] ||= "http://railscasts.com/login" if options[:
|
9
|
+
options[:rss_uri] ||= "http://feeds.feedburner.com/railscasts" unless options[:pro]
|
10
|
+
options[:login_uri] ||= "http://railscasts.com/login" if options[:pro]
|
11
11
|
@page = options[:page_explorer] || PageExplorer.new( options )
|
12
12
|
@rss = options[:rss_explorer] || RssExplorer.new( @page.get_rss_body )
|
13
|
+
@after = options[:after]
|
13
14
|
end
|
14
15
|
|
15
16
|
def get_all
|
@@ -21,7 +22,7 @@ module RailscastsDownload
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def videos_uris
|
24
|
-
@rss.get_uris
|
25
|
+
@rss.get_uris( after: @after )
|
25
26
|
end
|
26
27
|
|
27
28
|
def missing_videos_uris
|
@@ -13,4 +13,9 @@ class RssExplorerbTest < Test::Unit::TestCase
|
|
13
13
|
assert_equal( "http://media.railscasts.com/assets/episodes/videos/001-caching-with-instance-variables.mp4",
|
14
14
|
@rss.get_uris.first )
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
|
+
def test_get_uris_after_returns_correct_uris
|
18
|
+
assert_equal( "http://media.railscasts.com/assets/episodes/videos/336-copycopter.mp4",
|
19
|
+
@rss.get_uris( after: '2012-03-22' ).first )
|
20
|
+
end
|
21
|
+
end
|
data/test/stubs/rss_explorer.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: railscasts_download
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-03-30 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mechanize
|
16
|
-
requirement: &
|
16
|
+
requirement: &10965140 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *10965140
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: highline
|
27
|
-
requirement: &
|
27
|
+
requirement: &10964720 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *10964720
|
36
36
|
description: Download all revised and pro railscasts with oneline command.
|
37
37
|
email:
|
38
38
|
- karol@knowicki.pl
|
@@ -78,7 +78,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
78
|
version: '0'
|
79
79
|
segments:
|
80
80
|
- 0
|
81
|
-
hash:
|
81
|
+
hash: 2868771744563319319
|
82
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
87
|
version: '0'
|
88
88
|
segments:
|
89
89
|
- 0
|
90
|
-
hash:
|
90
|
+
hash: 2868771744563319319
|
91
91
|
requirements: []
|
92
92
|
rubyforge_project: railscasts_download
|
93
93
|
rubygems_version: 1.8.17
|