Merge branch 'neetzsche/include-scrobble-url' into 'develop'
Add optional URL value for scrobbles See merge request soapbox-pub/rebased!288
This commit is contained in:
commit
d92eef2967
4 changed files with 8 additions and 2 deletions
1
changelog.d/scrobble-url.add
Normal file
1
changelog.d/scrobble-url.add
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Adds the capability to add a URL to a scrobble (optional field)
|
|
@ -57,6 +57,7 @@ defp create_request do
|
||||||
album: %Schema{type: :string, description: "The album of the media playing"},
|
album: %Schema{type: :string, description: "The album of the media playing"},
|
||||||
artist: %Schema{type: :string, description: "The artist of the media playing"},
|
artist: %Schema{type: :string, description: "The artist of the media playing"},
|
||||||
length: %Schema{type: :integer, description: "The length of the media playing"},
|
length: %Schema{type: :integer, description: "The length of the media playing"},
|
||||||
|
url: %Schema{type: :string, description: "A URL referencing the media playing"},
|
||||||
visibility: %Schema{
|
visibility: %Schema{
|
||||||
allOf: [VisibilityScope],
|
allOf: [VisibilityScope],
|
||||||
default: "public",
|
default: "public",
|
||||||
|
@ -67,7 +68,8 @@ defp create_request do
|
||||||
"title" => "Some Title",
|
"title" => "Some Title",
|
||||||
"artist" => "Some Artist",
|
"artist" => "Some Artist",
|
||||||
"album" => "Some Album",
|
"album" => "Some Album",
|
||||||
"length" => 180_000
|
"length" => 180_000,
|
||||||
|
"url" => "https://www.last.fm/music/Some+Artist/_/Some+Title"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -81,6 +83,7 @@ defp scrobble do
|
||||||
title: %Schema{type: :string, description: "The title of the media playing"},
|
title: %Schema{type: :string, description: "The title of the media playing"},
|
||||||
album: %Schema{type: :string, description: "The album of the media playing"},
|
album: %Schema{type: :string, description: "The album of the media playing"},
|
||||||
artist: %Schema{type: :string, description: "The artist of the media playing"},
|
artist: %Schema{type: :string, description: "The artist of the media playing"},
|
||||||
|
url: %Schema{type: :string, description: "A URL referencing the media playing"},
|
||||||
length: %Schema{
|
length: %Schema{
|
||||||
type: :integer,
|
type: :integer,
|
||||||
description: "The length of the media playing",
|
description: "The length of the media playing",
|
||||||
|
@ -95,6 +98,7 @@ defp scrobble do
|
||||||
"artist" => "Some Artist",
|
"artist" => "Some Artist",
|
||||||
"album" => "Some Album",
|
"album" => "Some Album",
|
||||||
"length" => 180_000,
|
"length" => 180_000,
|
||||||
|
"url" => "https://www.last.fm/music/Some+Artist/_/Some+Title",
|
||||||
"created_at" => "2019-09-28T12:40:45.000Z"
|
"created_at" => "2019-09-28T12:40:45.000Z"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ def listen(user, params) do
|
||||||
defp listen_object(draft) do
|
defp listen_object(draft) do
|
||||||
object =
|
object =
|
||||||
draft.params
|
draft.params
|
||||||
|> Map.take([:album, :artist, :title, :length])
|
|> Map.take([:album, :artist, :title, :length, :url])
|
||||||
|> Map.new(fn {key, value} -> {to_string(key), value} end)
|
|> Map.new(fn {key, value} -> {to_string(key), value} end)
|
||||||
|> Map.put("type", "Audio")
|
|> Map.put("type", "Audio")
|
||||||
|> Map.put("to", draft.to)
|
|> Map.put("to", draft.to)
|
||||||
|
|
|
@ -27,6 +27,7 @@ def render("show.json", %{activity: %Activity{data: %{"type" => "Listen"}} = act
|
||||||
title: object.data["title"] |> HTML.strip_tags(),
|
title: object.data["title"] |> HTML.strip_tags(),
|
||||||
artist: object.data["artist"] |> HTML.strip_tags(),
|
artist: object.data["artist"] |> HTML.strip_tags(),
|
||||||
album: object.data["album"] |> HTML.strip_tags(),
|
album: object.data["album"] |> HTML.strip_tags(),
|
||||||
|
url: object.data["url"],
|
||||||
length: object.data["length"]
|
length: object.data["length"]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue