Adds country name to channel name

This commit is contained in:
freearhey 2023-11-15 12:37:20 +03:00
parent 4477d214a9
commit 615205de86
6 changed files with 22 additions and 10 deletions

View file

@ -16,7 +16,11 @@
let prevUrl = '/' let prevUrl = '/'
const onOpened = () => { const onOpened = () => {
prevUrl = window.location.href prevUrl = window.location.href
window.history.pushState({}, `${channel.name} • iptv-org`, `/channels/${country}/${name}`) window.history.pushState(
{},
`${channel.displayName} • iptv-org`,
`/channels/${country}/${name}`
)
} }
const onClose = () => { const onClose = () => {
window.history.pushState({}, `iptv-org`, prevUrl) window.history.pushState({}, `iptv-org`, prevUrl)
@ -24,7 +28,7 @@
const showStreams = () => const showStreams = () =>
open( open(
StreamsPopup, StreamsPopup,
{ streams, title: channel.name }, { streams, title: channel.displayName },
{ transitionBgProps: { duration: 0 }, transitionWindowProps: { duration: 0 } } { transitionBgProps: { duration: 0 }, transitionWindowProps: { duration: 0 } }
) )
const showChannelData = () => { const showChannelData = () => {
@ -74,7 +78,7 @@
loading="lazy" loading="lazy"
referrerpolicy="no-referrer" referrerpolicy="no-referrer"
src={channel.logo} src={channel.logo}
alt={channel.name} alt={channel.displayName}
/> />
{/if} {/if}
</div> </div>
@ -88,9 +92,9 @@
href="/channels/{country}/{name}" href="/channels/{country}/{name}"
tabindex="0" tabindex="0"
class="font-normal text-gray-600 dark:text-white hover:underline hover:text-blue-500 line-clamp-1" class="font-normal text-gray-600 dark:text-white hover:underline hover:text-blue-500 line-clamp-1"
title={channel.name} title={channel.displayName}
> >
{channel.name} {channel.displayName}
</a> </a>
{#if channel.is_closed} {#if channel.is_closed}
<div <div

View file

@ -22,7 +22,7 @@
class="flex justify-between items-center py-3 pl-5 pr-4 rounded-t border-b dark:border-gray-700" class="flex justify-between items-center py-3 pl-5 pr-4 rounded-t border-b dark:border-gray-700"
> >
<div class="w-2/3 overflow-hidden"> <div class="w-2/3 overflow-hidden">
<h3 class="text-l font-medium text-gray-900 dark:text-white">{channel.name}</h3> <h3 class="text-l font-medium text-gray-900 dark:text-white">{channel.displayName}</h3>
</div> </div>
<div class="inline-flex w-1/3 justify-end space-x-3 items-center"> <div class="inline-flex w-1/3 justify-end space-x-3 items-center">

View file

@ -4,7 +4,7 @@
export let channel export let channel
const endpoint = 'https://github.com/iptv-org/database/issues/new' const endpoint = 'https://github.com/iptv-org/database/issues/new'
const title = `Edit: ${channel.name}` const title = `Edit: ${channel.displayName}`
const labels = 'channels:edit' const labels = 'channels:edit'
const template = '__channels_edit.yml' const template = '__channels_edit.yml'

View file

@ -21,6 +21,7 @@ data.categories = _.keyBy(categories, 'id')
data.streams = _.groupBy(_streams, 'channel') data.streams = _.groupBy(_streams, 'channel')
data.blocklist = _.groupBy(blocklist, 'channel') data.blocklist = _.groupBy(blocklist, 'channel')
data.channels = _.keyBy(channels, channel => channel.id.toLowerCase()) data.channels = _.keyBy(channels, channel => channel.id.toLowerCase())
data.nameIndex = _.groupBy(channels, channel => channel.name.toLowerCase())
export const csr = true export const csr = true
export const ssr = true export const ssr = true

View file

@ -26,8 +26,8 @@
</script> </script>
<svelte:head> <svelte:head>
<title>{channel && channel.name ? `${channel.name} iptv-org` : 'iptv-org'}</title> <title>{channel && channel.displayName ? `${channel.displayName} iptv-org` : 'iptv-org'}</title>
<meta name="description" content="Detailed description of {channel.name}." /> <meta name="description" content="Detailed description of {channel.displayName}." />
{@html schema()} {@html schema()}
</svelte:head> </svelte:head>
@ -50,7 +50,7 @@
class="flex justify-between items-center py-3 pl-5 pr-4 rounded-t border-b dark:border-gray-700" class="flex justify-between items-center py-3 pl-5 pr-4 rounded-t border-b dark:border-gray-700"
> >
<div class="w-1/3 overflow-hidden"> <div class="w-1/3 overflow-hidden">
<h1 class="text-l font-medium text-gray-900 dark:text-white">{channel.name}</h1> <h1 class="text-l font-medium text-gray-900 dark:text-white">{channel.displayName}</h1>
</div> </div>
<div class="inline-flex w-1/3 justify-end space-x-3"> <div class="inline-flex w-1/3 justify-end space-x-3">
<EditButton {channel} /> <EditButton {channel} />

View file

@ -139,6 +139,8 @@ async function loadAPI() {
return [] return []
}) })
api.nameIndex = _.groupBy(api.channels, channel => channel.name.toLowerCase())
return api return api
} }
@ -163,6 +165,11 @@ export function transformChannel(channel, data) {
channel.is_blocked = !!data.blocklist[channel.id] channel.is_blocked = !!data.blocklist[channel.id]
channel.streams = channel._streams.length channel.streams = channel._streams.length
const isChannelNameRepeated = data.nameIndex[channel.name.toLowerCase()].length > 1
channel.displayName = isChannelNameRepeated
? `${channel.name} (${channel._country.name})`
: channel.name
return channel return channel
} }