program-tv 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 960be2b41388258787bc42008f5d5092628d858e
4
- data.tar.gz: 23f84646a0053115aa003df5bca05def2529c70c
3
+ metadata.gz: cdd826e88236e4397312508d2281c44dbfb4ce78
4
+ data.tar.gz: 4369235cebee6af25943fe94ccd1cb7b4350d387
5
5
  SHA512:
6
- metadata.gz: d94970f002742e6be5d4772b88191f7351e29046626de60af7a8c06b8b71dc131cbbb1f9357624e7d2d1173a748f804e841b81955782c86194500c6fd2823f3d
7
- data.tar.gz: b2e665e8d7eca5f6590e259b9d985536d0c982302aad4b9684997308631ad371a0c5f784fa61265501b7a41f3daff9bf84e5b23a1ee57e6631cf2a0a3b426401
6
+ metadata.gz: 415971534ac63f85bf06855d7b34b537f3d6d0978e210767ec63131c3eb10d740b09671a1baf61e60bfba919d8a3b1759c25e0db2e1ef3c66d65f68f4ceb86e7
7
+ data.tar.gz: 7bc7c87c47261aad47ab497a83c30c42015fcf818a442e8199d352bd55d585079d59072d7631fc75384725c2875cd63784e5e04733b41a5c37baa81139babcef
data/bin/program-tv CHANGED
@@ -5,29 +5,33 @@ $LOAD_PATH.push File.expand_path("../lib", File.dirname(__FILE__)) # add library
5
5
  require 'program-tv'
6
6
  require 'optparse'
7
7
 
8
- options = { layout: 'vertical', selector: 'img.sprite' }
9
- op = OptionParser.new
10
- op.banner = <<-eos
11
- #{ProgramTV::DESCRIPTION}
8
+ options = {}
9
+ OptionParser.new do |op|
10
+ op.banner = <<-eos
11
+ #{ProgramTV::DESCRIPTION}
12
12
 
13
- Usage: program-tv [options]
13
+ Usage: program-tv [options]
14
14
 
15
- eos
15
+ eos
16
16
 
17
- op.on("-h", "--help") do
18
- puts op.to_s
19
- exit!
20
- end
17
+ op.on("-h", "--help") do
18
+ puts op.to_s
19
+ exit!
20
+ end
21
21
 
22
- op.on("-v", "--version") do
23
- puts ProgramTV::VERSION
24
- exit!
25
- end
22
+ op.on("-v", "--version") do
23
+ puts ProgramTV::VERSION
24
+ exit!
25
+ end
26
+
27
+ op.on("-c", "--channel-list PATH", "path to yml channel list") do |path|
28
+ options[:channel_list] = path
29
+ end
30
+ end.parse!
26
31
 
27
32
  begin
28
- op.parse!(ARGV)
29
33
  ARGV.clear
30
- ProgramTV.run!
34
+ ProgramTV.run!(options)
31
35
  rescue Exception => ex
32
36
  puts ex.message
33
37
  exit!
data/channels.yml CHANGED
@@ -1,57 +1,51 @@
1
- - "ATM Rozrywka"
2
- - "4fun TV"
3
- - "Belsat TV"
4
- - "Bloomberg"
5
- - "CANAL+"
6
- - "CANAL+ Film"
7
- - "CANAL+ Film2"
8
- - "Deutsches Musik Fernsehen"
9
- - "Edusat"
10
- - "Edusat HD"
11
- - "Eska TV"
12
- - "Filmbox"
13
- - "France 24"
14
- - "France 23 - EN"
15
- - "HBO"
16
- - "HBO2"
17
- - "hbocomedy"
18
- - "itv"
19
- - "kinopolska"
20
- - "mango24"
21
- - "novelatv"
22
- - "polonia1"
23
- - "polotv"
24
- - "polsat"
25
- - "polsatjimjam"
26
- - "polsatsport"
27
- - "polsatsportnews"
28
- - "puls"
29
- - "puls2"
30
- - "rbltv"
31
- - "russiatoday"
32
- - "starstv"
33
- - "tele5"
34
- - "ttv"
35
- - "tv4"
36
- - "tv6"
37
- - "tvdisco"
38
- - "tvn"
39
- - "tvn24"
40
- - "tvn7"
41
- - "tvncnbc"
42
- - "tvnmeteo"
43
- - "tvnstyle"
44
- - "tvnturbo"
45
- - "tvp1"
46
- - "tvp2"
47
- - "tvphistoria"
48
- - "tvpinfo"
49
- - "tvpkultura"
50
- - "tvppolonia"
51
- - "tvprozrywka"
52
- - "tvr"
53
- - "tvs"
54
- - "tvtrwam"
55
- - "viasatexplorer"
56
- - "viasathistory"
57
- - "viasatnature"
1
+ atm-rozrywka : atmrozrywka
2
+ 4fun-tv : 4funtv
3
+ belsat-tv : belsat
4
+ bloomberg-(ang.) : bloomberg
5
+ deutsches-musik-fernsehen : deutschesmusik
6
+ edusat : edusat
7
+ eska-tv : eskatv
8
+ filmbox : filmbox
9
+ france-24 : france24
10
+ france-24-en : france24en
11
+ itv : itv
12
+ kino-polska : kinopolska
13
+ mango-24 : mango24
14
+ novela-tv : novelatv
15
+ polonia-1 : polonia1
16
+ polo-tv : polotv
17
+ polsat : polsat
18
+ polsat-biznes : polsatbiznes
19
+ jim-jam-polsat : polsatjimjam
20
+ polsat-sport : polsatsport
21
+ polsat-sport-news : polsatsportnews
22
+ puls : puls
23
+ puls-2 : puls2
24
+ rbl.tv : rbltv
25
+ russia-today : russiatoday
26
+ stars-tv : starstv
27
+ tele-5 : tele5
28
+ ttv : ttv
29
+ tv-4 : tv4
30
+ tv-6 : tv6
31
+ tv.disco : tvdisco
32
+ tvn : tvn
33
+ tvn-24 : tvn24
34
+ tvn-7 : tvn7
35
+ tvn-cnbc : tvncnbc
36
+ tvn-meteo : tvnmeteo
37
+ tvn-style : tvnstyle
38
+ tvn-turbo : tvnturbo
39
+ tvp-1 : tvp1
40
+ tvp-2 : tvp2
41
+ tvp-historia : tvphistoria
42
+ tvp-info : tvpinfo
43
+ tvp-kultura : tvpkultura
44
+ tvp-polonia : tvppolonia
45
+ tvp-rozrywka : tvprozrywka
46
+ tvr : tvr
47
+ tvs : tvs
48
+ tv-trwam : tvtrwam
49
+ polsat-viasat-explorer : viasatexplorer
50
+ polsat-viasat-history : viasathistory
51
+ polsat-viasat-nature : viasatnature
@@ -3,39 +3,32 @@ module ProgramTV
3
3
 
4
4
  def initialize
5
5
  @agent = Mechanize.new
6
- @channel_list_url = "http://www.cyfrowypolsat.pl/program-tv/lista-kanalow/"
7
6
  end
8
7
 
9
8
  # Runs dynamic-sprites command.
10
9
  #
11
10
  def run
12
- channel_urls.map do |url|
13
- schedule(url)
11
+ ProgramTV.selected_channels.map do |url_name, epg_name|
12
+ schedule(epg_name, "http://www.cyfrowypolsat.pl/program-tv/#{url_name}")
14
13
  end
15
14
  end
16
15
 
17
16
  private
18
17
 
19
- def schedule(url)
18
+ def schedule(epg_name, url)
20
19
  page = Nokogiri::HTML(@agent.get(url).body)
21
20
  data = page.css(".main.col > table:last > tbody > tr").map do |e|
22
21
  {
23
22
  start: running_time(e),
24
- channel: url.match(/([^\/]+)\/;/)[1].to_s,
23
+ channel: epg_name,
25
24
  title: e.css('.name').text
26
25
  }
27
26
  end
28
27
  data[0..-2].each_with_index{ |element, i| element[:end] = data[i+1][:start] }
29
- data.last[:end] = data.first[:start]
28
+ data.pop
30
29
  data
31
30
  end
32
31
 
33
- # Fetches page with channel list and returns Array of urls to subpages with channel schedule
34
- def channel_urls
35
- page = Nokogiri::HTML(@agent.get(@channel_list_url).body)
36
- page.css('.rowChannel a').select{ |c| ProgramTV.selected_channels.include?(c.text.to_s.strip) }.map{ |c| c.attr('href') }
37
- end
38
-
39
32
  # Methods to retrieve channel attributes
40
33
  def running_time(element)
41
34
  time = element.css('.time').text.match(/([0-9]+):([0-9]+)/)
data/lib/program-tv.rb CHANGED
@@ -2,7 +2,7 @@ module ProgramTV
2
2
 
3
3
  #----------------------------------------------------------------------------
4
4
 
5
- VERSION = "0.0.1"
5
+ VERSION = "0.0.3"
6
6
  SUMMARY = "TV Channel parser"
7
7
  DESCRIPTION = "Downloads TV channel list in XML format"
8
8
 
@@ -16,6 +16,7 @@ module ProgramTV
16
16
  # Initilizes Runner which controls all the magic stuff.
17
17
  #
18
18
  def self.run!(options = {})
19
+ @@options = options
19
20
  data = Parser.new.run
20
21
  puts Writer.new(data).run
21
22
  end
@@ -27,6 +28,6 @@ module ProgramTV
27
28
  end
28
29
 
29
30
  def self.selected_channels
30
- @channels ||= YAML::load(File.open(File.join(gem_root, 'channels.yml')))
31
+ @channels ||= YAML::load(File.open(@@options[:channel_list] || File.join(gem_root, 'channels.yml')))
31
32
  end
32
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: program-tv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Walusiak