Perlify scrobbles

FossilOrigin-Name: 8652ea3608a2a48af9f4915dd97732606cb8d5c5324821754472885d4f784a61
This commit is contained in:
nekobit 2022-08-13 06:16:21 +00:00
parent 4b696779ae
commit 6d46b56d54

View file

@ -845,6 +845,36 @@ AV* perlify_accounts(const struct mstdnt_account* accounts, size_t len)
return av;
}
HV* perlify_scrobble(const struct mstdnt_scrobble* scrobble)
{
if (!scrobble) return NULL;
HV* scrobble_hv = newHV();
hvstores_str(scrobble_hv, "account", perlify_account(scrobble->account));
hvstores_str(scrobble_hv, "album", scrobble->album);
hvstores_str(scrobble_hv, "artist", scrobble->artist);
hvstores_int(scrobble_hv, "created_at", scrobble->created_at);
hvstores_str(scrobble_hv, "id", scrobble->id);
hvstores_int(scrobble_hv, "length", scrobble->length);
hvstores_str(scrobble_hv, "title", scrobble->title);
return scrobble_hv;
}
AV* perlify_scrobbles(const struct mstdnt_scrobble* scrobbles, size_t len)
{
if (!(scrobbles && len)) return NULL;
AV* av = newAV();
av_extend(av, len-1);
for (int i = 0; i < len; ++i)
{
av_store(av, i, newRV_inc((SV*)perlify_scrobble(scrobbles + i)));
}
return av;
}
HV* perlify_account(const struct mstdnt_account* acct)
{
if (!acct) return NULL;