mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Merge pull request #574 from iptv-org/add-clickthecity.com
Add guide from clickthecity.com
This commit is contained in:
commit
101b0a06fc
5 changed files with 238 additions and 1 deletions
17
.github/workflows/clickthecity.com.yml
vendored
Normal file
17
.github/workflows/clickthecity.com.yml
vendored
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
name: clickthecity.com
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 * * *'
|
||||||
|
workflow_dispatch:
|
||||||
|
workflow_run:
|
||||||
|
workflows: [_trigger]
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
|
jobs:
|
||||||
|
load:
|
||||||
|
uses: ./.github/workflows/_load.yml
|
||||||
|
with:
|
||||||
|
site: ${{github.workflow}}
|
||||||
|
secrets:
|
||||||
|
APP_ID: ${{ secrets.APP_ID }}
|
||||||
|
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
|
|
@ -24,7 +24,12 @@ async function main() {
|
||||||
if (isPromise(channels)) {
|
if (isPromise(channels)) {
|
||||||
channels = await channels
|
channels = await channels
|
||||||
}
|
}
|
||||||
channels = _.sortBy(channels, 'xmltv_id')
|
channels = channels.map(c => {
|
||||||
|
c.lang = c.lang || 'en'
|
||||||
|
|
||||||
|
return c
|
||||||
|
})
|
||||||
|
channels = _.sortBy(channels, ['lang', 'xmltv_id'])
|
||||||
|
|
||||||
const dir = file.dirname(options.config)
|
const dir = file.dirname(options.config)
|
||||||
const outputFilepath = options.output || `${dir}/${config.site}.channels.xml`
|
const outputFilepath = options.output || `${dir}/${config.site}.channels.xml`
|
||||||
|
|
104
sites/clickthecity.com/clickthecity.com.config.js
Normal file
104
sites/clickthecity.com/clickthecity.com.config.js
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
const cheerio = require('cheerio')
|
||||||
|
const axios = require('axios')
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
const utc = require('dayjs/plugin/utc')
|
||||||
|
const timezone = require('dayjs/plugin/timezone')
|
||||||
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
|
|
||||||
|
dayjs.extend(utc)
|
||||||
|
dayjs.extend(timezone)
|
||||||
|
dayjs.extend(customParseFormat)
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
site: 'clickthecity.com',
|
||||||
|
url({ channel }) {
|
||||||
|
return `https://www.clickthecity.com/tv/network/${channel.site_id}`
|
||||||
|
},
|
||||||
|
request: {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'content-type': 'application/x-www-form-urlencoded'
|
||||||
|
},
|
||||||
|
data({ date }) {
|
||||||
|
const params = new URLSearchParams()
|
||||||
|
params.append('optDate', date.format('YYYY-MM-DD'))
|
||||||
|
params.append('optTime', '00:00:00')
|
||||||
|
|
||||||
|
return params
|
||||||
|
}
|
||||||
|
},
|
||||||
|
parser({ content, date }) {
|
||||||
|
const programs = []
|
||||||
|
const items = parseItems(content, date)
|
||||||
|
items.forEach(item => {
|
||||||
|
const prev = programs[programs.length - 1]
|
||||||
|
const $item = cheerio.load(item)
|
||||||
|
const start = parseStart($item, date)
|
||||||
|
const stop = parseStop($item, date)
|
||||||
|
if (stop && prev && stop.isBefore(prev.start)) return
|
||||||
|
programs.push({
|
||||||
|
title: parseTitle($item),
|
||||||
|
start,
|
||||||
|
stop
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return programs
|
||||||
|
},
|
||||||
|
async channels() {
|
||||||
|
const html = await axios
|
||||||
|
.get(`https://www.clickthecity.com/tv-networks/`)
|
||||||
|
.then(r => r.data)
|
||||||
|
.catch(console.log)
|
||||||
|
const $ = cheerio.load(html)
|
||||||
|
const items = $(
|
||||||
|
'#main > div > div > div > section.elementor-section.elementor-top-section.elementor-element.elementor-element-a3c51b3.elementor-section-boxed.elementor-section-height-default.elementor-section-height-default > div > div > div.elementor-column.elementor-col-50.elementor-top-column.elementor-element.elementor-element-b23e0a8 > div > div > div.elementor-element.elementor-element-b46952e.elementor-posts--align-center.elementor-grid-tablet-3.elementor-grid-mobile-3.elementor-grid-4.elementor-posts--thumbnail-top.elementor-widget.elementor-widget-posts > div > div > article'
|
||||||
|
).toArray()
|
||||||
|
|
||||||
|
return items.map(item => {
|
||||||
|
const name = $(item).find('div > h3').text().trim()
|
||||||
|
const url = $(item).find('a').attr('href')
|
||||||
|
const [_, site_id] = url.match(/network\/(.*)\//) || [null, null]
|
||||||
|
|
||||||
|
return {
|
||||||
|
site_id,
|
||||||
|
name
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseTitle($item) {
|
||||||
|
return $item('td > a').text().trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStart($item, date) {
|
||||||
|
const url = $item('td > a').attr('href') || ''
|
||||||
|
const [_, time] = url.match(/starttime=(\d{1,2}%3A\d{2}\+(AM|PM))/) || [null, null]
|
||||||
|
if (!time) return null
|
||||||
|
|
||||||
|
return dayjs.tz(
|
||||||
|
`${date.format('YYYY-MM-DD')} ${time.replace('%3A', ':')}`,
|
||||||
|
'YYYY-MM-DD h:mm A',
|
||||||
|
'Asia/Manila'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStop($item, date) {
|
||||||
|
const url = $item('td > a').attr('href') || ''
|
||||||
|
const [_, time] = url.match(/endtime=(\d{1,2}%3A\d{2}\+(AM|PM))/) || [null, null]
|
||||||
|
if (!time) return null
|
||||||
|
|
||||||
|
return dayjs.tz(
|
||||||
|
`${date.format('YYYY-MM-DD')} ${time.replace('%3A', ':')}`,
|
||||||
|
'YYYY-MM-DD h:mm A',
|
||||||
|
'Asia/Manila'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseItems(content, date) {
|
||||||
|
const $ = cheerio.load(content)
|
||||||
|
const stringDate = date.format('MMMM DD')
|
||||||
|
|
||||||
|
return $(`#tvlistings > tbody > tr:not(.bg-dark)`).toArray()
|
||||||
|
}
|
72
sites/clickthecity.com/clickthecity.com.test.js
Normal file
72
sites/clickthecity.com/clickthecity.com.test.js
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
// npm run channels:parse -- --config=./sites/clickthecity.com/clickthecity.com.config.js --output=./sites/clickthecity.com/clickthecity.com_ph.channels.xml
|
||||||
|
// npx epg-grabber --config=sites/clickthecity.com/clickthecity.com.config.js --channels=sites/clickthecity.com/clickthecity.com_ph.channels.xml --output=guide.xml --days=2
|
||||||
|
|
||||||
|
const { parser, url, request } = require('./clickthecity.com.config.js')
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
const utc = require('dayjs/plugin/utc')
|
||||||
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
|
dayjs.extend(customParseFormat)
|
||||||
|
dayjs.extend(utc)
|
||||||
|
|
||||||
|
const date = dayjs.utc('2022-03-05', 'YYYY-MM-DD').startOf('d')
|
||||||
|
const channel = {
|
||||||
|
site_id: 'tv5',
|
||||||
|
xmltv_id: 'TV5.ph'
|
||||||
|
}
|
||||||
|
|
||||||
|
it('can generate valid url', () => {
|
||||||
|
expect(url({ channel })).toBe('https://www.clickthecity.com/tv/network/tv5')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can generate valid request method', () => {
|
||||||
|
expect(request.method).toBe('POST')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can generate valid request headers', () => {
|
||||||
|
expect(request.headers).toMatchObject({
|
||||||
|
'content-type': 'application/x-www-form-urlencoded'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can generate valid request data', () => {
|
||||||
|
const result = request.data({ date })
|
||||||
|
expect(result.get('optDate')).toBe('2022-03-05')
|
||||||
|
expect(result.get('optTime')).toBe('00:00:00')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can parse response', () => {
|
||||||
|
const content = `<!doctypehtml><html class=html lang=en-US prefix="og: https://ogp.me/ns#"><body class="aa-prefix-click- content-right-sidebar default-breakpoint dropdown-mobile elementor-default elementor-kit-114471 elementor-page-62235 elementor-template-full-width has-breadcrumbs has-sidebar network-template-default oceanwp-theme page-header-disabled postid-62183 single single-network wp-custom-logo wp-embed-responsive"itemscope=itemscope itemtype=https://schema.org/WebPage><div class="clr site"id=outer-wrap><a class="screen-reader-text skip-link"href=#main>Skip to content</a><div class=clr id=wrap><main class="clr site-main"id=main role=main><div class="category-tv elementor elementor-62235 elementor-location-single entry has-media has-post-thumbnail hentry network post-62183 status-publish type-network"data-elementor-id=62235 data-elementor-settings=[] data-elementor-type=single><div class=elementor-section-wrap><section class="elementor-element elementor-section-height-default elementor-section-height-default elementor-element-9dc0219 elementor-section elementor-section-boxed elementor-top-section"data-element_type=section data-id=9dc0219><div class="elementor-column-gap-default elementor-container"><div class=elementor-row><div class="elementor-element elementor-col-50 elementor-column elementor-element-b6192ca elementor-top-column"data-element_type=column data-id=b6192ca data-settings='{"background_background":"classic"}'><div class="elementor-column-wrap elementor-element-populated"><div class=elementor-widget-wrap><div class="elementor-element elementor-element-c4989ed elementor-widget elementor-widget-shortcode"data-element_type=widget data-id=c4989ed data-widget_type=shortcode.default><div class=elementor-widget-container><div class=elementor-shortcode><form class=form-inline id=frmTV method=POST name=frmTV role=form><div class=w-100><table class="card d-table overflow-hidden rounded shadow table table-bordered table-striped"id=tvlistings><tr class="bg-dark text-light"><th colspan=2>Tomorrow, March 05<tr><td class=cTme width=100>12:00 am<td class="cPrg showlnkcon"><a class="font-weight-bold text-dark"href="/tv/tvshow.php?id=109793&starttime=12%3A00+AM&endtime=1%3A00+AM"name=0>CCF Worship Service</a><tr><td class=cTme width=100>06:30 am<td class="cPrg showlnkcon"><a class="font-weight-bold text-dark"href="/tv/tvshow.php?id=94697&starttime=6%3A30+AM&endtime=7%3A30+AM"name=1>Word Of God</a><tr class="bg-dark text-light"><th colspan="2">Tonight, March 05</th></tr><tr> <td class="cTme">08:00 pm</td><td class="cPrg showlnkcon"> <a class="font-weight-bold text-dark" name="10" href="/tv/tvshow.php?id=113538&starttime=8%3A00+PM&endtime=9%3A00+PM">Rated Korina S2 </a> </td></tr><tr class="bg-dark text-light"><th colspan=2>Sunday, March 06<tr><td class=cTme>12:00 am<td class="cPrg showlnkcon"><a class="font-weight-bold text-dark"href="/tv/tvshow.php?id=114754&starttime=12%3A00+AM&endtime=3%3A30+AM"name=13>2021 PBA Governor's Cup</a></table></div></form></div></div></div></div></div></div></div></div></section></div></div></main></div></div>`
|
||||||
|
|
||||||
|
const result = parser({ content, date }).map(p => {
|
||||||
|
p.start = p.start.toJSON()
|
||||||
|
p.stop = p.stop.toJSON()
|
||||||
|
return p
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(result).toMatchObject([
|
||||||
|
{
|
||||||
|
start: '2022-03-04T16:00:00.000Z',
|
||||||
|
stop: '2022-03-04T17:00:00.000Z',
|
||||||
|
title: `CCF Worship Service`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
start: '2022-03-04T22:30:00.000Z',
|
||||||
|
stop: '2022-03-04T23:30:00.000Z',
|
||||||
|
title: `Word Of God`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
start: '2022-03-05T12:00:00.000Z',
|
||||||
|
stop: '2022-03-05T13:00:00.000Z',
|
||||||
|
title: `Rated Korina S2`
|
||||||
|
}
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can handle empty guide', () => {
|
||||||
|
const result = parser({
|
||||||
|
date,
|
||||||
|
channel,
|
||||||
|
content: `<!DOCTYPE html><html class="html" lang="en-US" prefix="og: https://ogp.me/ns#"><head></head><body></body></html>`
|
||||||
|
})
|
||||||
|
expect(result).toMatchObject([])
|
||||||
|
})
|
39
sites/clickthecity.com/clickthecity.com_ph.channels.xml
Normal file
39
sites/clickthecity.com/clickthecity.com_ph.channels.xml
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<site site="clickthecity.com">
|
||||||
|
<channels>
|
||||||
|
<channel lang="en" xmltv_id="A2ZChannel11.ph" site_id="a2z-channel-11">A2Z Channel 11</channel>
|
||||||
|
<channel lang="en" xmltv_id="ANC.ph" site_id="anc">ANC</channel>
|
||||||
|
<channel lang="en" xmltv_id="AnimaxPhilippines.jp" site_id="animax">Animax</channel>
|
||||||
|
<channel lang="en" xmltv_id="AXNPhilippines.us" site_id="axn">AXN</channel>
|
||||||
|
<channel lang="en" xmltv_id="CelestialMoviesPinoy.hk" site_id="celestial-movies-pinoy">Celestial Movies Pinoy</channel>
|
||||||
|
<channel lang="en" xmltv_id="CinemaOneGlobal.ph" site_id="cinema-one">Cinema One</channel>
|
||||||
|
<channel lang="en" xmltv_id="CinemaxAsia.us" site_id="cinemax">Cinemax</channel>
|
||||||
|
<channel lang="en" xmltv_id="CNNPhilippines.us" site_id="cnn-philippines">CNN Philippines</channel>
|
||||||
|
<channel lang="en" xmltv_id="CrimePlusInvestigationAsia.us" site_id="crime-investigation">Crime & Investigation</channel>
|
||||||
|
<channel lang="en" xmltv_id="IBC13.ph" site_id="ibc-tv-13">IBC 13</channel>
|
||||||
|
<channel lang="en" xmltv_id="ETC.ph" site_id="etc">ETC</channel>
|
||||||
|
<channel lang="en" xmltv_id="Gem.in" site_id="gem">GEM</channel>
|
||||||
|
<channel lang="en" xmltv_id="GMANews.ph" site_id="gma-news-tv">GMA News TV</channel>
|
||||||
|
<channel lang="en" xmltv_id="GMATV.ph" site_id="gma">GMA</channel>
|
||||||
|
<channel lang="en" xmltv_id="GTV.ph" site_id="gtv">GTV</channel>
|
||||||
|
<channel lang="en" xmltv_id="HBOAsia.us" site_id="hbo-asia">HBO Asia</channel>
|
||||||
|
<channel lang="en" xmltv_id="HistoryPhilippines.us" site_id="history">History</channel>
|
||||||
|
<channel lang="en" xmltv_id="JeepneyTV.ph" site_id="jeepney-tv">Jeepney TV</channel>
|
||||||
|
<channel lang="en" xmltv_id="KapamilyaChannel.ph" site_id="kapamilya-channel">Kapamilya Channel</channel>
|
||||||
|
<channel lang="en" xmltv_id="KMoviesPinoy.ph" site_id="k-movies-pinoy">K Movies Pinoy</channel>
|
||||||
|
<channel lang="en" xmltv_id="Liga.ph" site_id="liga">Liga</channel>
|
||||||
|
<channel lang="en" xmltv_id="MetroChannel.ph" site_id="metro-channel">Metro Channel</channel>
|
||||||
|
<channel lang="en" xmltv_id="MyxPhilippines.ph" site_id="myx">MYX</channel>
|
||||||
|
<channel lang="en" xmltv_id="NationalGeographicPhilippines.us" site_id="national-geographic">National Geographic</channel>
|
||||||
|
<channel lang="en" xmltv_id="Net25.ph" site_id="net-25">Net 25</channel>
|
||||||
|
<channel lang="en" xmltv_id="NickelodeonPhilippines.us" site_id="nickelodeon">Nickelodeon</channel>
|
||||||
|
<channel lang="en" xmltv_id="PBO.ph" site_id="pbo">PBO</channel>
|
||||||
|
<channel lang="en" xmltv_id="PTV.ph" site_id="ptv">PTV</channel>
|
||||||
|
<channel lang="en" xmltv_id="RockEntertainment.sg" site_id="rock-entertainment">Rock Entertainment</channel>
|
||||||
|
<channel lang="en" xmltv_id="RockExtreme.sg" site_id="rock-extreme">Rock Extreme</channel>
|
||||||
|
<channel lang="en" xmltv_id="TeleNovelaChannel.ph" site_id="telenovela-channel">TeleNovela Channel</channel>
|
||||||
|
<channel lang="en" xmltv_id="TMC.ph" site_id="tagalized-movie-channel">Tagalized Movie Channel</channel>
|
||||||
|
<channel lang="en" xmltv_id="TV5.ph" site_id="tv5">TV5</channel>
|
||||||
|
<channel lang="en" xmltv_id="VivaCinema.ph" site_id="viva-tv">VIVA Cinema</channel>
|
||||||
|
</channels>
|
||||||
|
</site>
|
Loading…
Add table
Add a link
Reference in a new issue