JOCHLSDownloader 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +4 -0
  2. data/lib/JOCHLSDownloader.rb +9 -6
  3. metadata +1 -1
data/README.md CHANGED
@@ -4,6 +4,10 @@ JOCHLSDownloader
4
4
 
5
5
  The JOCHLSDownloader is a very simple native ruby code that downloads all files linked by a m3u8 manifest
6
6
 
7
+ Note:
8
+ For LIVE and EVENT playlist types it downloads only the firsts media segments.
9
+ For VOD playlist type it will download all media content.
10
+
7
11
  Usage examples:
8
12
 
9
13
  ```ruby
@@ -42,10 +42,11 @@ class CJOCHLSDownloader
42
42
  #Get domain
43
43
  domain = @sourceurl.host
44
44
  url = @sourceurl.path
45
+ port = @sourceurl.port
45
46
 
46
47
  Log Logger::DEBUG, "URI host: #{domain}, path: #{url}"
47
48
 
48
- downloadHLS domain, url, @destpath
49
+ downloadHLS domain, port, url, @destpath
49
50
 
50
51
  end
51
52
 
@@ -54,9 +55,10 @@ private
54
55
  #Download a m3u8 file and call to parse function
55
56
  #
56
57
  # @param domain [String] Source domain to download m3u8 file
58
+ # @param port [int] Port to connect
57
59
  # @param url [String] Source url path to download m3u8 file
58
60
  # @param basedir [String] local filesystem path to save the downloaded files
59
- def downloadHLS (domain, url, basedir)
61
+ def downloadHLS (domain, port, url, basedir)
60
62
  Log Logger::DEBUG, "downloadHLS domain: #{domain}, URL: #{url}, basedir: #{basedir}"
61
63
 
62
64
  if Dir.exist?(basedir) == false
@@ -69,7 +71,7 @@ private
69
71
 
70
72
  Log Logger::DEBUG, "Start downloading domain: #{domain}, URL: #{url}, To: #{destpathfile}"
71
73
 
72
- Net::HTTP.start(domain) do |http|
74
+ Net::HTTP.start(domain, port) do |http|
73
75
  resp = http.get(url)
74
76
  open(destpathfile, "wb") do |file|
75
77
  file.write(resp.body)
@@ -81,7 +83,7 @@ private
81
83
  ext = File.extname (destpathfile)
82
84
  if ext.casecmp(".m3u8") == 0
83
85
  Log Logger::DEBUG, "Start parsing: #{destpathfile}"
84
- parsem3u8 destpathfile,domain, url, basedir
86
+ parsem3u8 destpathfile, domain, port, url, basedir
85
87
  Log Logger::DEBUG, "End parsing: #{destpathfile}"
86
88
  end
87
89
  end
@@ -90,9 +92,10 @@ private
90
92
  #
91
93
  # @param file [String] path to donwloaded m3u8 to parse
92
94
  # @param domain [String] Source domain of downloaded m3u8 file
95
+ # @param port [int] Port to connect
93
96
  # @param url [String] Source url path to downloaded m3u8 file
94
97
  # @param basedir [String] local filesystem path to save the downloaded files
95
- def parsem3u8 (file, domain, url, basedir)
98
+ def parsem3u8 (file, domain, port, url, basedir)
96
99
 
97
100
  File.open( file ).each do |line|
98
101
 
@@ -115,7 +118,7 @@ private
115
118
  newbasedir = basedir
116
119
  end
117
120
 
118
- downloadHLS domain, newurl, newbasedir
121
+ downloadHLS domain, port, newurl, newbasedir
119
122
  end
120
123
  end
121
124
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: JOCHLSDownloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: