Skip to content

Commit

Permalink
Customized for new version of web site
Browse files Browse the repository at this point in the history
  • Loading branch information
shvets committed Mar 14, 2010
1 parent db68def commit 006ff28
Show file tree
Hide file tree
Showing 28 changed files with 321 additions and 258 deletions.
6 changes: 5 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@

== Version 0.5.0

* Bug fixes, adding support for main menu
* Bug fixes, adding support for main menu

== Version 0.7.0

* Customized for new version of web site
4 changes: 2 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
Usage: etvnet_seek [options] keywords
-s, --search Display Search Menu
-r, --runglish Enter russian keywords in translit
-b, --best-ten Display Best 10 Menu
-p, --popular Display Popular Menu
-b, --best-hunred Display Best 100 Menu
-w, --we-recommend Display We recommend Menu
-c, --channels Display Channels Menu
-a, --catalog Display Catalog Menu
-m, --main Display Main Menu
-h, --help Display this screen
2 changes: 1 addition & 1 deletion bin/etvnet_seek
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ link_info = client.seek ARGV.join(' ')

if not link_info.nil? and link_info.resolved?
puts "Link #{link_info.text} [#{link_info.name} (#{link_info.media_file})]: #{link_info.link}"
puts "#{link_info.rtsp_link}"
#puts "#{link_info.rtsp_link}"

launch = ask("Launch link (y/n)?")

Expand Down
2 changes: 1 addition & 1 deletion etvnet_seek.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require "rake"

Gem::Specification.new do |s|
s.name = %q{etvnet_seek}
s.version = "0.6.1"
s.version = "0.7.0"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=

Expand Down
26 changes: 13 additions & 13 deletions lib/etvnet_seek/commander.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def initialize
end

def search_mode?
@options[:runglish]
@options[:search]
end

def runglish_mode?
Expand All @@ -16,14 +16,14 @@ def runglish_mode?
def get_initial_mode
if @options[:search] == true
'search'
elsif @options[:best_ten] == true
'best_ten'
elsif @options[:popular] == true
'popular'
elsif @options[:best_hundred] == true
'best_hundred'
elsif @options[:we_recommend] == true
'we_recommend'
elsif @options[:channels] == true
'channels'
elsif @options[:catalog] == true
'catalog'
else
'main'
end
Expand Down Expand Up @@ -52,14 +52,9 @@ def parse_options
options[:runglish] = true
end

options[:best_ten] = false
opts.on( '-b', '--best-ten', 'Display Best 10 Menu' ) do
options[:best_ten] = true
end

options[:popular] = false
opts.on( '-p', '--popular', 'Display Popular Menu' ) do
options[:popular] = true
options[:best_hundred] = false
opts.on( '-b', '--best-hundred', 'Display Best 100 Menu' ) do
options[:best_hundred] = true
end

options[:we_recommend] = false
Expand All @@ -72,6 +67,11 @@ def parse_options
options[:channels] = true
end

options[:catalog] = false
opts.on( '-a', '--catalog', 'Display Catalog Menu' ) do
options[:popular] = true
end

options[:main] = false
opts.on( '-m', '--main', 'Display Main Menu' ) do
options[:main] = true
Expand Down
45 changes: 36 additions & 9 deletions lib/etvnet_seek/cookie_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,67 @@ def load_cookie
end

def save_cookie cookie
return if cookie.nil?

File.open(@cookie_file_name, 'w') { |file| file.puts cookie }
end

def delete_cookie
File.delete @cookie_file_name if File.exist? @cookie_file_name
end

def self.get_auth_and_expires cookie
length = "auth=".length
# def self.get_expires cookie
# length = "expires=".length
#
# #auth = ""
# expires = ""
#
# fragment = cookie
#
# while true do
# position = fragment.index("expires=")
#
# break if position == -1
#
# if fragment[position+length..position+length] != ";"
# right_position = fragment[position..-1].index(";")
# #auth = fragment[position+length..position+right_position-1]
#
# pos1 = position+right_position+1+"expires=".length+1
# pos2 = fragment[pos1..-1].index(";")
# expires = fragment[pos1..pos1+pos2-1]
# break
# else
# fragment = fragment[position+length+1..-1]
# end
# end
#
# [auth, expires]
# end

def self.get_expires cookie
length = "expires=".length

auth = ""
expires = ""

fragment = cookie

while true do
position = fragment.index("auth=")
position = fragment.index("expires=")

break if position == -1

if fragment[position+length..position+length] != ";"
right_position = fragment[position..-1].index(";")
auth = fragment[position+length..position+right_position-1]
expires = fragment[position+length..position+right_position-1]

pos1 = position+right_position+1+"expires=".length+1
pos2 = fragment[pos1..-1].index(";")
expires = fragment[pos1..pos1+pos2-1]
break
else
fragment = fragment[position+length+1..-1]
end
end

[auth, expires]
expires
end

def self.get_username cookie
Expand Down
9 changes: 5 additions & 4 deletions lib/etvnet_seek/core/access_page.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
class AccessPage < ServiceCall
ACCESS_URL = Page::BASE_URL + "/cgi-bin/video/access.fcgi"
ACCESS_URL = Page::BASE_URL + "/watch_new/"

def initialize
super(ACCESS_URL)
end

def request_media_info media_file, cookie
params = { 'action' => 'start_video', 'bitrate' => '600',
'media_file'=> media_file, 'replay' => '1', 'skin' => 'JSON' }
params = { 'bitrate' => '2', 'view' => 'submit'}
headers = { 'Cookie' => cookie }

@url += "#{media_file}/"

response = post(params, headers)

MediaInfo.new JSON.parse(response.body)["PARAMETERS"]
MediaInfo.new Nokogiri::HTML(response.body).css("ref").at(0).attributes["href"].text
end

end
20 changes: 8 additions & 12 deletions lib/etvnet_seek/core/announces_page.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class AnnouncesPage < MediaPage
ANNOUNCES_URL = BASE_URL + "/announces.html"
ANNOUNCES_URL = BASE_URL + "/announces/"

def initialize()
super(ANNOUNCES_URL)
Expand All @@ -12,20 +12,16 @@ def category_breadcrumbs
def items
list = []

document.css("table tr td div").each do |item|
unless item.css("a").at(0).nil?
image = item.css("img").at(0).attributes['src'].value.strip
document.css(".gallery ul li").each do |item|
text = item.css("a img").at(0).attributes['alt'].value.strip
link = item.css("a").at(1)

unless image == 'images/banner_announces.jpg'
text = item.css("img").at(0).attributes['alt'].value.strip
href = item.css("a").at(0).attributes['href'].value
image = item.css("img").at(0).attributes['src'].value.strip
unless link.nil?
href = link.attributes['href'].value

record = BrowseMediaItem.new(text, href)
record.image = image
record = BrowseMediaItem.new(text, href)

list << record
end
list << record
end
end

Expand Down
49 changes: 0 additions & 49 deletions lib/etvnet_seek/core/archive_media_page.rb

This file was deleted.

6 changes: 2 additions & 4 deletions lib/etvnet_seek/core/base_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ class BasePage < Page
def items
list = []

document.css("#tblCategories a").each do |item|
document.css("#nav a").each do |item|
text = item.css("img").at(0).attributes['alt'].value
href = item['href']

unless href =~ /(forum|action=browse_persons|valentines2010)/
list << MediaItem.new(text, href)
end
list << MediaItem.new(text, href)
end

list.delete_at(0)
Expand Down
4 changes: 2 additions & 2 deletions lib/etvnet_seek/core/browse_media_item.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class BrowseMediaItem < MediaItem
attr_accessor :folder, :showtime, :year, :duration, :image, :rating_image, :channel
attr_accessor :folder, :showtime, :year, :duration, :image, :rating_image, :rating, :channel

def initialize(text, link)
super(text, link)
Expand Down Expand Up @@ -34,7 +34,7 @@ def to_s
buffer += " --- #{channel}" if channel
buffer += " --- #{image}" if image
buffer += " --- #{rating_image}" if rating_image

buffer
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ArchiveMediaItem < MediaItem
class CatalogItem < MediaItem
attr_accessor :folder, :showtime, :duration, :year, :rating_image, :rating, :channel

def folder?
Expand Down
8 changes: 4 additions & 4 deletions lib/etvnet_seek/core/channel_media_item.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
class ChannelMediaItem < MediaItem
attr_reader :archive_link
attr_reader :catalog_link

def initialize(text, link, archive_link)
def initialize(text, link, catalog_link)
super(text, link)

@archive_link = archive_link
@catalog_link = catalog_link
end

def channel
link[link.index("channel=") + "channel=".size, link.size-1]
link.scan(/\/(\w*)/)[2]
end

def to_s
Expand Down
15 changes: 7 additions & 8 deletions lib/etvnet_seek/core/channels_page.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class ChannelsPage < MediaPage
BROWSE_URL = BASE_URL + "/cgi-bin/video/eitv_browse.fcgi"
CHANNELS_URL = BROWSE_URL + "?action=channels"
CHANNELS_URL = BASE_URL + "/tv_channels/"

def initialize url = CHANNELS_URL
super(url)
Expand All @@ -9,25 +8,25 @@ def initialize url = CHANNELS_URL
def items
list = []

document.css("table table table.rounded_white table tr").each do |item|
links = item.css("table tr td a")
document.css(".table-all-kanali tr").each do |item|
links = item.css("td a")

text = item.children.at(0).text.strip

if text.size > 0
link = nil
archive_link = nil
catalog_link = nil

if links.size > 0
href = links[0]
archive_href = links[1]
catalog_href = links[1]

link = href.attributes['href'].value unless href.nil?

archive_link = archive_href.attributes['href'].value unless archive_href.nil?
catalog_link = catalog_href.attributes['href'].value unless catalog_href.nil?
end

list << ChannelMediaItem.new(text, link, archive_link) unless link.nil?
list << ChannelMediaItem.new(text, link, catalog_link) unless link.nil?
end
end

Expand Down
Loading

0 comments on commit 006ff28

Please sign in to comment.