etvnet-seek 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/CHANGES +26 -0
  2. data/Gemfile +14 -0
  3. data/README +20 -0
  4. data/Rakefile +59 -0
  5. data/VERSION +1 -0
  6. data/bin/etvnet-seek +27 -0
  7. data/bin/etvnet-seek.bat +6 -0
  8. data/etvnet-seek.gemspec +98 -0
  9. data/lib/etvnet_seek/commander.rb +105 -0
  10. data/lib/etvnet_seek/cookie_helper.rb +107 -0
  11. data/lib/etvnet_seek/core/access_page.rb +19 -0
  12. data/lib/etvnet_seek/core/base_page.rb +43 -0
  13. data/lib/etvnet_seek/core/browse_media_item.rb +41 -0
  14. data/lib/etvnet_seek/core/catalog_item.rb +38 -0
  15. data/lib/etvnet_seek/core/catalog_page.rb +29 -0
  16. data/lib/etvnet_seek/core/channel_media_item.rb +17 -0
  17. data/lib/etvnet_seek/core/channels_page.rb +29 -0
  18. data/lib/etvnet_seek/core/group_media_item.rb +7 -0
  19. data/lib/etvnet_seek/core/group_page.rb +42 -0
  20. data/lib/etvnet_seek/core/home_page.rb +18 -0
  21. data/lib/etvnet_seek/core/login_page.rb +49 -0
  22. data/lib/etvnet_seek/core/media_info.rb +31 -0
  23. data/lib/etvnet_seek/core/media_item.rb +52 -0
  24. data/lib/etvnet_seek/core/media_page.rb +41 -0
  25. data/lib/etvnet_seek/core/new_item.rb +9 -0
  26. data/lib/etvnet_seek/core/new_items_page.rb +20 -0
  27. data/lib/etvnet_seek/core/page.rb +19 -0
  28. data/lib/etvnet_seek/core/page_factory.rb +51 -0
  29. data/lib/etvnet_seek/core/search_page.rb +42 -0
  30. data/lib/etvnet_seek/core/service_call.rb +32 -0
  31. data/lib/etvnet_seek/easy_auth.rb +52 -0
  32. data/lib/etvnet_seek/etvnet_seek.rb +10 -0
  33. data/lib/etvnet_seek/link_info.rb +37 -0
  34. data/lib/etvnet_seek/main.rb +180 -0
  35. data/lib/etvnet_seek/user_selection.rb +26 -0
  36. data/lib/media_converter.rb +85 -0
  37. data/lib/progressbar.rb +237 -0
  38. data/lib/runglish.rb +131 -0
  39. data/spec/etvnet_seek_spec.rb +28 -0
  40. metadata +200 -0
data/CHANGES ADDED
@@ -0,0 +1,26 @@
1
+
2
+ = Etvnet-seek Gem Changelog
3
+
4
+ == Version 0.1.0
5
+
6
+ * Initial release.
7
+
8
+ == Version 0.2.0
9
+
10
+ * Bug fixes, code for Windows
11
+
12
+ == Version 0.3.0
13
+
14
+ * Bug fixes, support for Runglish (you can enter russian string as latin one)
15
+
16
+ == Version 0.4.0
17
+
18
+ * Bug fixes, adding support for main menu
19
+
20
+ == Version 0.5.0
21
+
22
+ * Bug fixes, adding support for main menu
23
+
24
+ == Version 0.7.0
25
+
26
+ * Customized for new version of web site
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "gemcutter"
4
+ gem "jeweler"
5
+ gem "sinatra"
6
+ gem "nokogiri"
7
+ gem "libxml-ruby"
8
+ gem "zipit"
9
+ gem "highline"
10
+ gem "json_pure"
11
+ gem "rake"
12
+
13
+ gem "rspec", :require => "spec"
14
+ gem "mocha"
data/README ADDED
@@ -0,0 +1,20 @@
1
+ = Etvnet Seek Gem -- Command line tool for getting mms urls from etvnet service.
2
+
3
+ = Installing Etvnet Seek
4
+
5
+ == Installing the Gem
6
+ $ sudo gem sources -a http://gemcutter.org
7
+ $ sudo gem install etvnet-seek
8
+
9
+ == Usage
10
+
11
+ Usage: etvnet-seek [options] keywords
12
+ -s, --search Display Search Menu
13
+ -r, --runglish Enter russian keywords in translit
14
+ -b, --best-hunred Display Best 100 Menu
15
+ -n, --new_items Display New Items Menu
16
+ -p, --premier Display Premier of the Week Menu
17
+ -c, --channels Display Channels Menu
18
+ -a, --catalog Display Catalog Menu
19
+ -m, --main Display Main Menu
20
+ -h, --help Display this screen
@@ -0,0 +1,59 @@
1
+ require 'rubygems' unless RUBY_VERSION =~ /1.9.*/
2
+
3
+ require 'rake'
4
+ require 'spec/rake/spectask'
5
+
6
+ begin
7
+ require 'zipit'
8
+ rescue LoadError
9
+ puts "Zipit is not available. Install it with: sudo gem install zipit"
10
+ end
11
+
12
+ begin
13
+ require 'jeweler'
14
+ Jeweler::Tasks.new do |gemspec|
15
+ gemspec.name = "etvnet-seek"
16
+ gemspec.summary = "Accessing etvnet service from command line."
17
+ gemspec.description = "Command line tool for getting mms urls from etvnet service."
18
+ gemspec.email = "alexander.shvets@gmail.com"
19
+ gemspec.homepage = "http://github.com/shvets/etvnet-seek"
20
+ gemspec.authors = ["Alexander Shvets"]
21
+ gemspec.files = FileList["CHANGES", "etvnet-seek.gemspec", "Rakefile", "Gemfile", "README", "VERSION", "lib/**/*", "bin/**"]
22
+ gemspec.add_dependency("json_pure", ">= 1.2.0")
23
+ gemspec.add_dependency("highline", ">= 1.5.1")
24
+ gemspec.add_dependency("libxml-ruby", ">= 1.1.3")
25
+ gemspec.add_dependency("nokogiri", ">= 1.4.1")
26
+
27
+ gemspec.add_development_dependency "rspec", ">= 1.2.9"
28
+ gemspec.add_development_dependency "mocha", ">= 0.9.7"
29
+
30
+ gemspec.executables = ['etvnet-seek']
31
+ gemspec.requirements = ["none"]
32
+ gemspec.bindir = "bin"
33
+ end
34
+ Jeweler::GemcutterTasks.new
35
+ rescue LoadError
36
+ puts "Jeweler not available. Install it with: sudo gem install technicalsteaks-jeweler -s http://gems.github.com"
37
+ end
38
+
39
+ task :zip do
40
+ zip :archive => "etvnet-seek.zip", :dir => "."
41
+ end
42
+
43
+ desc "Run gem code locally"
44
+ task :"run:gem" do
45
+ command = "bin/etvnet-seek"
46
+ puts ruby("#{command}")
47
+ end
48
+
49
+ # configure rspec
50
+ Spec::Rake::SpecTask.new do |spec|
51
+ spec.spec_files = FileList["spec/**/*_spec.rb"]
52
+ spec.spec_opts << "--color"
53
+ spec.libs += ["lib", "spec"]
54
+ end
55
+
56
+ task :default => :zip
57
+
58
+
59
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.7.2
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ require 'rubygems' unless RUBY_VERSION =~ /1.9.*/
5
+
6
+ $:.unshift(File::join(File::dirname(File::dirname(__FILE__)), "lib"))
7
+
8
+ $KCODE='u'
9
+
10
+ require 'etvnet_seek/etvnet_seek'
11
+ require 'etvnet_seek/main'
12
+
13
+ trap('INT') { puts "Program was interrupted..."; exit }
14
+
15
+ client = Main.new
16
+
17
+ link_info = client.seek ARGV.join(' ')
18
+
19
+ if not link_info.nil? and link_info.resolved?
20
+ puts "Link #{link_info.text} [#{link_info.name} (#{link_info.media_file})]: #{link_info.link}"
21
+ #puts "#{link_info.rtsp_link}"
22
+
23
+ launch = ask("Launch link (y/n)?")
24
+
25
+ client.launch_link link_info.link if launch =~ /y/i
26
+ end
27
+
@@ -0,0 +1,6 @@
1
+ @ECHO OFF
2
+ IF NOT "%~f0" == "~f0" GOTO :WinNT
3
+ @"ruby.exe" "C:/Ruby/ruby-1.9.1/bin/etvnet-seek" %1 %2 %3 %4 %5 %6 %7 %8 %9
4
+ GOTO :EOF
5
+ :WinNT
6
+ @"ruby.exe" "%~dpn0" %*
@@ -0,0 +1,98 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{etvnet-seek}
8
+ s.version = "0.7.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Alexander Shvets"]
12
+ s.date = %q{2010-07-11}
13
+ s.default_executable = %q{etvnet-seek}
14
+ s.description = %q{Command line tool for getting mms urls from etvnet service.}
15
+ s.email = %q{alexander.shvets@gmail.com}
16
+ s.executables = ["etvnet-seek"]
17
+ s.extra_rdoc_files = [
18
+ "README"
19
+ ]
20
+ s.files = [
21
+ "CHANGES",
22
+ "Gemfile",
23
+ "README",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "bin/etvnet-seek",
27
+ "bin/etvnet-seek.bat",
28
+ "etvnet-seek.gemspec",
29
+ "lib/etvnet_seek/commander.rb",
30
+ "lib/etvnet_seek/cookie_helper.rb",
31
+ "lib/etvnet_seek/core/access_page.rb",
32
+ "lib/etvnet_seek/core/base_page.rb",
33
+ "lib/etvnet_seek/core/browse_media_item.rb",
34
+ "lib/etvnet_seek/core/catalog_item.rb",
35
+ "lib/etvnet_seek/core/catalog_page.rb",
36
+ "lib/etvnet_seek/core/channel_media_item.rb",
37
+ "lib/etvnet_seek/core/channels_page.rb",
38
+ "lib/etvnet_seek/core/group_media_item.rb",
39
+ "lib/etvnet_seek/core/group_page.rb",
40
+ "lib/etvnet_seek/core/home_page.rb",
41
+ "lib/etvnet_seek/core/login_page.rb",
42
+ "lib/etvnet_seek/core/media_info.rb",
43
+ "lib/etvnet_seek/core/media_item.rb",
44
+ "lib/etvnet_seek/core/media_page.rb",
45
+ "lib/etvnet_seek/core/new_item.rb",
46
+ "lib/etvnet_seek/core/new_items_page.rb",
47
+ "lib/etvnet_seek/core/page.rb",
48
+ "lib/etvnet_seek/core/page_factory.rb",
49
+ "lib/etvnet_seek/core/search_page.rb",
50
+ "lib/etvnet_seek/core/service_call.rb",
51
+ "lib/etvnet_seek/easy_auth.rb",
52
+ "lib/etvnet_seek/etvnet_seek.rb",
53
+ "lib/etvnet_seek/link_info.rb",
54
+ "lib/etvnet_seek/main.rb",
55
+ "lib/etvnet_seek/user_selection.rb",
56
+ "lib/media_converter.rb",
57
+ "lib/progressbar.rb",
58
+ "lib/runglish.rb"
59
+ ]
60
+ s.homepage = %q{http://github.com/shvets/etvnet-seek}
61
+ s.rdoc_options = ["--charset=UTF-8"]
62
+ s.require_paths = ["lib"]
63
+ s.requirements = ["none"]
64
+ s.rubygems_version = %q{1.3.7}
65
+ s.summary = %q{Accessing etvnet service from command line.}
66
+ s.test_files = [
67
+ "spec/etvnet_seek_spec.rb"
68
+ ]
69
+
70
+ if s.respond_to? :specification_version then
71
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
72
+ s.specification_version = 3
73
+
74
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
75
+ s.add_runtime_dependency(%q<json_pure>, [">= 1.2.0"])
76
+ s.add_runtime_dependency(%q<highline>, [">= 1.5.1"])
77
+ s.add_runtime_dependency(%q<libxml-ruby>, [">= 1.1.3"])
78
+ s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.1"])
79
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
80
+ s.add_development_dependency(%q<mocha>, [">= 0.9.7"])
81
+ else
82
+ s.add_dependency(%q<json_pure>, [">= 1.2.0"])
83
+ s.add_dependency(%q<highline>, [">= 1.5.1"])
84
+ s.add_dependency(%q<libxml-ruby>, [">= 1.1.3"])
85
+ s.add_dependency(%q<nokogiri>, [">= 1.4.1"])
86
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
87
+ s.add_dependency(%q<mocha>, [">= 0.9.7"])
88
+ end
89
+ else
90
+ s.add_dependency(%q<json_pure>, [">= 1.2.0"])
91
+ s.add_dependency(%q<highline>, [">= 1.5.1"])
92
+ s.add_dependency(%q<libxml-ruby>, [">= 1.1.3"])
93
+ s.add_dependency(%q<nokogiri>, [">= 1.4.1"])
94
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
95
+ s.add_dependency(%q<mocha>, [">= 0.9.7"])
96
+ end
97
+ end
98
+
@@ -0,0 +1,105 @@
1
+ class Commander
2
+ attr_accessor :mode
3
+
4
+ def initialize
5
+ @options = parse_options
6
+ end
7
+
8
+ def search_mode?
9
+ @options[:search]
10
+ end
11
+
12
+ def runglish_mode?
13
+ @options[:runglish]
14
+ end
15
+
16
+ def get_initial_mode
17
+ if @options[:search] == true
18
+ 'search'
19
+ elsif @options[:best_hundred] == true
20
+ 'best_hundred'
21
+ elsif @options[:channels] == true
22
+ 'channels'
23
+ elsif @options[:catalog] == true
24
+ 'catalog'
25
+ elsif @options[:new_items] == true
26
+ 'new_items'
27
+ elsif @options[:premiere] == true
28
+ 'premiere'
29
+ else
30
+ 'main'
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def parse_options
37
+ # This hash will hold all of the options
38
+ # parsed from the command-line by
39
+ # OptionParser.
40
+ options = {}
41
+
42
+ optparse = OptionParser.new do |opts|
43
+ # Set a banner, displayed at the top
44
+ # of the help screen.
45
+ opts.banner = "Usage: etvnet-seek [options] keywords"
46
+
47
+ options[:search] = false
48
+ opts.on('-s', '--search', 'Display Search Menu') do
49
+ options[:search] = true
50
+ end
51
+
52
+ options[:runglish] = false
53
+ opts.on('-r', '--runglish', 'Enter russian keywords in translit') do
54
+ options[:runglish] = true
55
+ end
56
+
57
+ options[:best_hundred] = false
58
+ opts.on('-b', '--best-hundred', 'Display Best 100 Menu') do
59
+ options[:best_hundred] = true
60
+ end
61
+
62
+ options[:channels] = false
63
+ opts.on('-c', '--channels', 'Display Channels Menu') do
64
+ options[:channels] = true
65
+ end
66
+
67
+ options[:catalog] = false
68
+ opts.on('-a', '--catalog', 'Display Catalog Menu') do
69
+ options[:catalog] = true
70
+ end
71
+
72
+ options[:main] = false
73
+ opts.on('-m', '--main', 'Display Main Menu') do
74
+ options[:main] = true
75
+ end
76
+
77
+ options[:new_items] = false
78
+ opts.on('-n', '--new_items', 'New Items Menu') do
79
+ options[:new_items] = true
80
+ end
81
+
82
+ options[:premiere] = false
83
+ opts.on('-p', '--premiere', 'Premiere of the Week Menu') do
84
+ options[:premiere] = true
85
+ end
86
+
87
+ # This displays the help screen, all programs are
88
+ # assumed to have this option.
89
+ opts.on('-h', '--help', 'Display this screen') do
90
+ puts opts
91
+ exit
92
+ end
93
+ end
94
+
95
+ optparse.parse!
96
+
97
+ if options[:runglish] && !options[:search]
98
+ puts "Please use -r option together with -s option."
99
+ exit
100
+ end
101
+
102
+ options
103
+ end
104
+
105
+ end
@@ -0,0 +1,107 @@
1
+ class CookieHelper
2
+
3
+ def initialize cookie_file_name
4
+ @cookie_file_name = cookie_file_name
5
+ end
6
+
7
+ def load_cookie
8
+ File.exist?(@cookie_file_name) ? read_cookie : nil
9
+ end
10
+
11
+ def save_cookie cookie
12
+ return if cookie.nil?
13
+
14
+ File.open(@cookie_file_name, 'w') { |file| file.puts cookie }
15
+ end
16
+
17
+ def delete_cookie
18
+ File.delete @cookie_file_name if File.exist? @cookie_file_name
19
+ end
20
+
21
+ # def self.get_expires cookie
22
+ # length = "expires=".length
23
+ #
24
+ # #auth = ""
25
+ # expires = ""
26
+ #
27
+ # fragment = cookie
28
+ #
29
+ # while true do
30
+ # position = fragment.index("expires=")
31
+ #
32
+ # break if position == -1
33
+ #
34
+ # if fragment[position+length..position+length] != ";"
35
+ # right_position = fragment[position..-1].index(";")
36
+ # #auth = fragment[position+length..position+right_position-1]
37
+ #
38
+ # pos1 = position+right_position+1+"expires=".length+1
39
+ # pos2 = fragment[pos1..-1].index(";")
40
+ # expires = fragment[pos1..pos1+pos2-1]
41
+ # break
42
+ # else
43
+ # fragment = fragment[position+length+1..-1]
44
+ # end
45
+ # end
46
+ #
47
+ # [auth, expires]
48
+ # end
49
+
50
+ def self.get_expires cookie
51
+ p cookie
52
+ length = "expires=".length
53
+
54
+ expires = ""
55
+
56
+ fragment = cookie
57
+
58
+ while true do
59
+ position = fragment.index("expires=")
60
+
61
+ break if position == -1
62
+
63
+ if fragment[position+length..position+length] != ";"
64
+ right_position = fragment[position..-1].index(";")
65
+ expires = fragment[position+length..position+right_position-1]
66
+
67
+ break
68
+ else
69
+ fragment = fragment[position+length+1..-1]
70
+ end
71
+ end
72
+
73
+ expires
74
+ end
75
+
76
+ def self.get_username cookie
77
+ length = "username=".length
78
+
79
+ username = ""
80
+
81
+ fragment = cookie
82
+
83
+ while true do
84
+ position = fragment.index("username=")
85
+
86
+ break if position == -1
87
+
88
+ if fragment[position+length..position+length] != ";"
89
+ right_position = fragment[position..-1].index(";")
90
+ username = fragment[position+length..position+right_position-1]
91
+
92
+ break
93
+ else
94
+ fragment = fragment[position+length+1..-1]
95
+ end
96
+ end
97
+
98
+ username
99
+ end
100
+
101
+ private
102
+
103
+ def read_cookie
104
+ File.open(@cookie_file_name, 'r') { |file| file.gets }
105
+ end
106
+
107
+ end