Skip to content

Commit

Permalink
Enhancement: use tubearchivist stats endpoints (#3814)
Browse files Browse the repository at this point in the history
  • Loading branch information
shamoon committed Aug 3, 2024
1 parent 0d6aabc commit 8fba3ee
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
4 changes: 2 additions & 2 deletions docs/widgets/services/tubearchivist.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ description: Tube Archivist Widget Configuration

Learn more about [Tube Archivist](https://github.com/tubearchivist/tubearchivist).

Requires API key.
You must be running at least version 0.4.4

Allowed fields: `["downloads", "videos", "channels", "playlists"]`.

```yaml
widget:
type: tubearchivist
url: http://tubearchivist.host.or.ip
key: apikeyapikeyapikeyapikeyapikey
key: tubearchivistapikey
```
14 changes: 4 additions & 10 deletions src/widgets/tubearchivist/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,10 @@ export default function Component({ service }) {

return (
<Container service={service}>
<Block
label="tubearchivist.downloads"
value={t("common.number", { value: downloadsData?.paginate?.total_hits })}
/>
<Block label="tubearchivist.videos" value={t("common.number", { value: videosData?.paginate?.total_hits })} />
<Block label="tubearchivist.channels" value={t("common.number", { value: channelsData?.paginate?.total_hits })} />
<Block
label="tubearchivist.playlists"
value={t("common.number", { value: playlistsData?.paginate?.total_hits })}
/>
<Block label="tubearchivist.downloads" value={t("common.number", { value: downloadsData.pending ?? 0 })} />
<Block label="tubearchivist.videos" value={t("common.number", { value: videosData.doc_count ?? 0 })} />
<Block label="tubearchivist.channels" value={t("common.number", { value: channelsData.doc_count ?? 0 })} />
<Block label="tubearchivist.playlists" value={t("common.number", { value: playlistsData.doc_count ?? 0 })} />
</Container>
);
}
19 changes: 11 additions & 8 deletions src/widgets/tubearchivist/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@ const widget = {

mappings: {
downloads: {
endpoint: "download",
validate: ["paginate"],
endpoint: "stats/download",
validate: ["pending"],
},
videos: {
endpoint: "video",
validate: ["paginate"],
endpoint: "stats/video",
validate: ["doc_count"],
},
channels: {
endpoint: "channel",
validate: ["paginate"],
endpoint: "stats/channel",
validate: ["doc_count"],
},
playlists: {
endpoint: "playlist",
validate: ["paginate"],
endpoint: "stats/playlist",
validate: ["doc_count"],
},
stats: {
endpoint: "stats",
},
},
};
Expand Down

0 comments on commit 8fba3ee

Please sign in to comment.