-module(webls@rss).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([to_string/1]).
-export_type([rss_channel/0, rss_item/0]).
-type rss_channel() :: {rss_channel,
binary(),
binary(),
binary(),
list(rss_item())}.
-type rss_item() :: {rss_item,
binary(),
binary(),
binary(),
birl:time(),
gleam@option:option(binary()),
{binary(), gleam@option:option(boolean())}}.
-spec rss_item_to_string(rss_item()) -> binary().
rss_item_to_string(Item) ->
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"- \n"/utf8, ""/utf8>>/binary,
(erlang:element(
2,
Item
))/binary>>/binary,
"\n"/utf8>>/binary,
""/utf8>>/binary,
(erlang:element(3, Item))/binary>>/binary,
"\n"/utf8>>/binary,
""/utf8>>/binary,
(erlang:element(4, Item))/binary>>/binary,
"\n"/utf8>>/binary,
""/utf8>>/binary,
(begin
_pipe = erlang:element(5, Item),
birl:to_iso8601(_pipe)
end)/binary>>/binary,
"\n"/utf8>>/binary,
(case erlang:element(6, Item) of
{some, Author} ->
<<<<""/utf8, Author/binary>>/binary,
"\n"/utf8>>;
_ ->
<<""/utf8>>
end)/binary>>/binary,
(case erlang:element(7, Item) of
{Guid, {some, Is_permalink}} ->
<<<<<<<<"
<<"true"/utf8>>;
false ->
<<"false"/utf8>>
end)/binary>>/binary, "\">"/utf8>>/binary, Guid/binary>>/binary, "\n"/utf8>>;
_ ->
<<""/utf8>>
end)/binary>>/binary,
"
"/utf8>>.
-spec channel_to_string(rss_channel()) -> binary().
channel_to_string(Channel) ->
Channel_items = begin
_pipe = erlang:element(5, Channel),
_pipe@2 = gleam@list:map(_pipe, fun(Rss_item) -> _pipe@1 = Rss_item,
rss_item_to_string(_pipe@1) end),
_pipe@3 = gleam@list:reduce(
_pipe@2,
fun(Acc, Rss_item_string) ->
<<<>/binary, Rss_item_string/binary>>
end
),
gleam@result:unwrap(_pipe@3, <<""/utf8>>)
end,
<<<<<<<<<<<<<<<<<<<<<<"\n\n"/utf8, ""/utf8>>/binary,
(erlang:element(2, Channel))/binary>>/binary,
"\n"/utf8>>/binary,
""/utf8>>/binary,
(erlang:element(3, Channel))/binary>>/binary,
"\n"/utf8>>/binary,
""/utf8>>/binary,
(erlang:element(4, Channel))/binary>>/binary,
"\n"/utf8>>/binary,
Channel_items/binary>>/binary,
""/utf8>>.
-spec to_string(list(rss_channel())) -> binary().
to_string(Channels) ->
Channel_content = begin
_pipe = Channels,
_pipe@2 = gleam@list:map(_pipe, fun(Channel) -> _pipe@1 = Channel,
channel_to_string(_pipe@1) end),
_pipe@3 = gleam@list:reduce(
_pipe@2,
fun(Acc, Channel_string) ->
<<<>/binary, Channel_string/binary>>
end
),
gleam@result:unwrap(_pipe@3, <<""/utf8>>)
end,
<<<<"\n"/utf8,
Channel_content/binary>>/binary,
"\n"/utf8>>.