Add top track to weekly post

This commit is contained in:
2023-03-05 22:54:18 +11:00
parent ea9d092505
commit 03bf0eca9f
9 changed files with 95 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
require "lastfm"
require "time_math"
module Adamantium
module Queries
module Posts
class TopTracks
include Deps["settings", "repos.post_repo"]
def call(slug:)
post = post_repo.fetch!(slug)
lastfm = Lastfm.new(settings.lastfm_api_key, settings.lastfm_secret)
lastfm.user.get_weekly_track_chart(user: "dNitza", from: TimeMath.week.floor(post.published_at).to_i, to: TimeMath.week.ceil(post.published_at).to_i)
end
end
end
end
end