From 21b8ce87318e929bcfe2a9f01ed2b865e63fc6f2 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sun, 12 Dec 2021 07:11:50 +0300 Subject: [PATCH] Create scripts/store/getters --- scripts/store/getters/group_title.js | 12 ++++++++++++ scripts/store/getters/index.js | 7 +++++++ scripts/store/getters/title.js | 13 +++++++++++++ scripts/store/getters/tvg_country.js | 5 +++++ scripts/store/getters/tvg_id.js | 3 +++ scripts/store/getters/tvg_language.js | 3 +++ scripts/store/getters/tvg_logo.js | 3 +++ scripts/store/getters/tvg_url.js | 3 +++ 8 files changed, 49 insertions(+) create mode 100644 scripts/store/getters/group_title.js create mode 100644 scripts/store/getters/index.js create mode 100644 scripts/store/getters/title.js create mode 100644 scripts/store/getters/tvg_country.js create mode 100644 scripts/store/getters/tvg_id.js create mode 100644 scripts/store/getters/tvg_language.js create mode 100644 scripts/store/getters/tvg_logo.js create mode 100644 scripts/store/getters/tvg_url.js diff --git a/scripts/store/getters/group_title.js b/scripts/store/getters/group_title.js new file mode 100644 index 0000000000..ddae6ef2b6 --- /dev/null +++ b/scripts/store/getters/group_title.js @@ -0,0 +1,12 @@ +module.exports = function () { + if (this.group_title) return this.group_title + + if (Array.isArray(this.categories)) { + return this.categories + .map(i => i.name) + .sort() + .join(';') + } + + return '' +} diff --git a/scripts/store/getters/index.js b/scripts/store/getters/index.js new file mode 100644 index 0000000000..df20631e05 --- /dev/null +++ b/scripts/store/getters/index.js @@ -0,0 +1,7 @@ +exports.group_title = require('./group_title') +exports.title = require('./title') +exports.tvg_country = require('./tvg_country') +exports.tvg_id = require('./tvg_id') +exports.tvg_language = require('./tvg_language') +exports.tvg_logo = require('./tvg_logo') +exports.tvg_url = require('./tvg_url') diff --git a/scripts/store/getters/title.js b/scripts/store/getters/title.js new file mode 100644 index 0000000000..7dc8304a67 --- /dev/null +++ b/scripts/store/getters/title.js @@ -0,0 +1,13 @@ +module.exports = function () { + let title = this.name + + if (this.resolution.height) { + title += ` (${this.resolution.height}p)` + } + + if (this.status.label) { + title += ` [${this.status.label}]` + } + + return title +} diff --git a/scripts/store/getters/tvg_country.js b/scripts/store/getters/tvg_country.js new file mode 100644 index 0000000000..7865e26b38 --- /dev/null +++ b/scripts/store/getters/tvg_country.js @@ -0,0 +1,5 @@ +module.exports = function () { + if (this.tvg_country) return this.tvg_country + + return Array.isArray(this.countries) ? this.countries.map(i => i.code).join(';') : '' +} diff --git a/scripts/store/getters/tvg_id.js b/scripts/store/getters/tvg_id.js new file mode 100644 index 0000000000..6b362cefe4 --- /dev/null +++ b/scripts/store/getters/tvg_id.js @@ -0,0 +1,3 @@ +module.exports = function () { + return this.id || '' +} diff --git a/scripts/store/getters/tvg_language.js b/scripts/store/getters/tvg_language.js new file mode 100644 index 0000000000..2ad39c7fec --- /dev/null +++ b/scripts/store/getters/tvg_language.js @@ -0,0 +1,3 @@ +module.exports = function () { + return Array.isArray(this.languages) ? this.languages.map(i => i.name).join(';') : '' +} diff --git a/scripts/store/getters/tvg_logo.js b/scripts/store/getters/tvg_logo.js new file mode 100644 index 0000000000..e5d62bc9df --- /dev/null +++ b/scripts/store/getters/tvg_logo.js @@ -0,0 +1,3 @@ +module.exports = function () { + return this.logo || '' +} diff --git a/scripts/store/getters/tvg_url.js b/scripts/store/getters/tvg_url.js new file mode 100644 index 0000000000..9bd084c789 --- /dev/null +++ b/scripts/store/getters/tvg_url.js @@ -0,0 +1,3 @@ +module.exports = function () { + return this.guides.length ? this.guides[0] : '' +}