Skip to content

Commit

Permalink
Merge pull request #3689 from pooza/dev/4.31.5
Browse files Browse the repository at this point in the history
4.31.5
  • Loading branch information
pooza authored Jun 9, 2024
2 parents cdaf171 + e20c6f7 commit 3e52565
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 25 deletions.
38 changes: 20 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,23 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actionpack (7.1.3.3)
actionview (= 7.1.3.3)
activesupport (= 7.1.3.3)
actionpack (7.1.3.4)
actionview (= 7.1.3.4)
activesupport (= 7.1.3.4)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
actionview (7.1.3.3)
activesupport (= 7.1.3.3)
actionview (7.1.3.4)
activesupport (= 7.1.3.4)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activesupport (7.1.3.3)
activesupport (7.1.3.4)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
Expand All @@ -119,9 +119,9 @@ GEM
base64 (0.2.0)
bigdecimal (3.1.8)
bson (5.0.0)
builder (3.2.4)
builder (3.3.0)
cgi (0.4.1)
concurrent-ruby (1.3.1)
concurrent-ruby (1.3.2)
connection_pool (2.4.1)
crass (1.0.6)
csv (3.3.0)
Expand Down Expand Up @@ -170,12 +170,14 @@ GEM
etc (1.4.3)
eventmachine (1.2.7)
facets (3.1.0)
faraday (2.9.0)
faraday (2.9.1)
faraday-net_http (>= 2.0, < 3.2)
faraday-net_http (3.1.0)
net-http
fastimage (2.3.1)
ffi (1.16.3)
ffi (1.17.0)
ffi (1.17.0-aarch64-linux-gnu)
ffi (1.17.0-x86_64-linux-gnu)
fileutils (1.7.2)
find (0.2.0)
fugit (1.11.0)
Expand Down Expand Up @@ -208,10 +210,10 @@ GEM
marcel (1.0.4)
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0507)
mime-types-data (3.2024.0604)
mini_magick (4.12.0)
mini_mime (1.1.5)
mini_portile2 (2.8.6)
mini_portile2 (2.8.7)
minitest (5.23.1)
mongo (2.20.0)
bson (>= 4.14.1, < 6.0.0)
Expand All @@ -223,7 +225,7 @@ GEM
mutex_m (0.2.0)
net-http (0.4.1)
uri
net-imap (0.4.11)
net-imap (0.4.12)
date
net-protocol
net-pop (0.1.2)
Expand Down Expand Up @@ -256,7 +258,7 @@ GEM
oauth2 (>= 1.4, < 3)
omniauth (~> 2.0)
optparse (0.5.0)
parallel (1.24.0)
parallel (1.25.1)
parser (3.3.2.0)
ast (~> 2.4.1)
racc
Expand Down Expand Up @@ -296,8 +298,8 @@ GEM
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.2.8)
strscan (>= 3.0.9)
rexml (3.2.9)
strscan
ricecream (0.2.1)
rspotify (2.12.2)
addressable (~> 2.8.0)
Expand Down Expand Up @@ -338,7 +340,7 @@ GEM
sassc (2.4.0)
ffi (~> 1.9)
securerandom (0.3.1)
sequel (5.80.0)
sequel (5.81.0)
bigdecimal
set (1.1.0)
sidekiq (7.2.4)
Expand Down Expand Up @@ -373,7 +375,7 @@ GEM
tilt (2.1.0)
time (0.3.0)
date
timecop (0.9.8)
timecop (0.9.9)
timeout (0.4.1)
trollop (2.9.10)
tzinfo (2.0.6)
Expand Down
11 changes: 8 additions & 3 deletions app/lib/mulukhiya/controller/api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class APIController < Controller

get '/program/works/:id/episodes' do
raise Ginseng::AuthError, 'Unauthorized' unless annict = account_class.info_account.annict
@renderer.message = annict.episodes(params[:id].to_i).map do |episode|
@renderer.message = annict.episodes([params[:id].to_i]).map do |episode|
episode.merge(
url: episode['url'].to_s,
hashtag_url: episode['hashtag_uri'].to_s,
Expand Down Expand Up @@ -433,8 +433,13 @@ class APIController < Controller
get '/tagging/dic/annict/episodes' do
raise Ginseng::NotFoundError, 'Not Found' unless controller_class.annict?
raise Ginseng::AuthError, 'Unauthorized' unless annict = account_class.info_account.annict
ids = annict.works.map {|v| v['annictId']}
@renderer.message = annict.episodes(ids.join(',')).to_h {|v| [v['title'], []]}
episodes = annict.episodes(annict.works.map {|v| v['annictId'].to_i})
@renderer.message = episodes.to_h do |episode|
if (num = episode['numberText']) && (matches = num.match(/[0-9]+/))
num = "#{matches[0]}話"
end
[episode['title'], [num].compact]
end
return @renderer.to_s
rescue => e
e.log
Expand Down
4 changes: 2 additions & 2 deletions app/lib/mulukhiya/service/annict_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def works(keyword = nil)
return works.sort_by {|v| (v['seasonYear'].to_i * 100_000) + v['annictId']}.reverse
end

def episodes(id)
return unless entries = query(:episodes, {ids: [id]}).dig('data', 'searchWorks', 'nodes')
def episodes(ids)
return unless entries = query(:episodes, {ids:}).dig('data', 'searchWorks', 'nodes')
all = []
entries.map {|v| v.dig('episodes', 'nodes')}.each do |episodes|
episodes.each do |episode|
Expand Down
2 changes: 1 addition & 1 deletion config/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ package:
- tkoishi@b-shock.co.jp
license: MIT
url: https://github.com/pooza/mulukhiya-toot-proxy
version: 4.31.4
version: 4.31.5
parser:
note:
fields:
Expand Down
2 changes: 1 addition & 1 deletion test/annict_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_works

def test_episodes
id = @service.works.filter_map {|v| v['annictId']}.last
@service.episodes(id).each do |episode|
@service.episodes([id]).each do |episode|
assert_kind_of(String, episode['numberText'])
assert_kind_of(String, episode['title'])
assert_kind_of(String, episode['hashtag'])
Expand Down

0 comments on commit 3e52565

Please sign in to comment.