Skip to content

Commit

Permalink
Fixing Dzen downloader
Browse files Browse the repository at this point in the history
  • Loading branch information
weshatheleopard committed Nov 3, 2024
1 parent cbb07c9 commit b90727b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
24 changes: 13 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,30 @@ GEM
domain_name (0.6.20240107)
http-cookie (1.0.7)
domain_name (~> 0.5)
mechanize (2.12.0)
logger (1.6.1)
mechanize (2.12.2)
addressable (~> 2.8)
base64
domain_name (~> 0.5, >= 0.5.20190701)
http-cookie (~> 1.0, >= 1.0.3)
mime-types (~> 3.0)
mime-types (~> 3.3)
net-http-digest_auth (~> 1.4, >= 1.4.1)
net-http-persistent (>= 2.5.2, < 5.0.dev)
nkf
nokogiri (~> 1.11, >= 1.11.2)
rubyntlm (~> 0.6, >= 0.6.3)
webrick (~> 1.7)
webrobots (~> 0.1.2)
mime-types (3.5.2)
mime-types (3.6.0)
logger
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0820)
mime-types-data (3.2024.1001)
net-http-digest_auth (1.4.1)
net-http-persistent (4.0.2)
net-http-persistent (4.0.4)
connection_pool (~> 2.2)
net-sftp (4.0.0)
net-ssh (>= 5.0.0, < 8.0.0)
net-ssh (7.2.3)
net-ssh (7.3.0)
nkf (0.2.0)
nokogiri (1.15.6-x86_64-linux)
racc (~> 1.4)
Expand All @@ -43,12 +45,12 @@ GEM
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-core (3.13.2)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.2)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.1)
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
Expand All @@ -60,10 +62,10 @@ GEM
sync (0.5.0)
term-ansicolor (1.11.2)
tins (~> 1.0)
tins (1.33.0)
tins (1.37.0)
bigdecimal
sync
webrick (1.8.1)
webrick (1.9.0)
webrobots (0.1.2)

PLATFORMS
Expand Down
13 changes: 5 additions & 8 deletions lib/downloaders/dzen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@ def get_track_list(url)
agent.cookie_jar.add(Mechanize::Cookie.new('zen_vk_sso_checked', '1', :domain => '.dzen.ru', :path => '/'))

page = agent.get(url)
match_data = page.content.match(/\(\((?<json>{"data":{"MICRO_APP_SSR_DATA"(.+))\)\)/)
match_data = page.content.match(/var _params=\((?<json>{"ssrData":(.+))\);/);1
json = JSON::parse match_data['json']

data1 = json.dig('data', 'MICRO_APP_SSR_DATA', 'settings', 'exportData', 'video')

video_id = data1['publicationObjectId']
data1 = json.dig('ssrData',"videoMetaResponse")
video_id = data1['id']
created_at = Time.at(data1['publicationDate'].to_i).to_date.strftime('%F')
title = data1['title']

data = data1.dig('rawStreams', 'SingleStream', 0)

title = data['Title']

data = json.dig('ssrData', "streamsResponse", "SingleStream", 0)
data2 = data.dig('StreamInfo').find { |h| h['StreamType'] == 'ST_HLS' }
res_selection_url = data2['OutputStream']

Expand Down

0 comments on commit b90727b

Please sign in to comment.