Skip to content

Commit

Permalink
Adding more data to Rutube downloader
Browse files Browse the repository at this point in the history
  • Loading branch information
weshatheleopard committed May 13, 2024
1 parent 87b0ae3 commit 16f306e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/downloaders/rutube.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ def get_track_list(url)
title = json['title']

m3u_data = M3UParser.new(agent.get(json.dig('video_balancer', 'm3u8')).content).parse
max_res_playlist_url = m3u_data[:entries].max_by{ |entry| entry['RESOLUTION'].to_i }[:url]
mex_res_entry = m3u_data[:entries].max_by{ |entry| entry['RESOLUTION'].to_i }
max_res_playlist_url = mex_res_entry[:url]

track_list = M3UParser.new(agent.get(max_res_playlist_url).content).extract_tracklist(max_res_playlist_url)

{ id: video_id, track_list: track_list, title: title, created: created_at }
{ id: video_id, track_list: track_list, title: title, created: created_at, resolution: mex_res_entry['RESOLUTION'] }
end
end
7 changes: 3 additions & 4 deletions lib/video_downloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,10 @@ def download_video_by_url(source_url, combine: false)

prefix = data[:id]
urls = data[:track_list]
title = data[:title]
created = data[:created]

puts "Video title: #{title.white.bold}" if title
puts "Video created: #{created.white.bold}" if created
{ title: 'Title', created: 'Created', resolution: 'Resolution' }.each_pair { |k, v|
puts "Video #{v}: #{data[k].white.bold}" if data&.has_key?(k)
}

print "Downloading segments... #{@save_pos}"

Expand Down

0 comments on commit 16f306e

Please sign in to comment.