Replace LF line endings with CRLF

This commit is contained in:
freearhey
2025-09-28 17:55:05 +03:00
parent efc74efcf8
commit b6a589c62a
1192 changed files with 445631 additions and 445631 deletions
+15 -15
View File
@@ -1,15 +1,15 @@
# www3.nhk.or.jp
https://www3.nhk.or.jp/nhkworld/ _[Geo-blocked]_
### Download the guide
```sh
npm run grab --- --site=www3.nhk.or.jp
```
### Test
```sh
npm test --- www3.nhk.or.jp
```
# www3.nhk.or.jp
https://www3.nhk.or.jp/nhkworld/ _[Geo-blocked]_
### Download the guide
```sh
npm run grab --- --site=www3.nhk.or.jp
```
### Test
```sh
npm test --- www3.nhk.or.jp
```
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<channels>
<channel site="www3.nhk.or.jp" lang="en" xmltv_id="NHKWorldJapan.jp" site_id="0">NHK World-Japan</channel>
<?xml version="1.0"?>
<channels>
<channel site="www3.nhk.or.jp" lang="en" xmltv_id="NHKWorldJapan.jp" site_id="0">NHK World-Japan</channel>
</channels>
+68 -68
View File
@@ -1,68 +1,68 @@
const dayjs = require('dayjs')
module.exports = {
site: 'www3.nhk.or.jp',
days: 5,
lang: 'en',
delay: 5000,
url: function ({ date }) {
return `https://nwapi.nhk.jp/nhkworld/epg/v7b/world/s${date.unix() * 1000}-e${
date.add(1, 'd').unix() * 1000
}.json`
},
request: {
method: 'GET',
timeout: 5000,
cache: { ttl: 60 * 1000 },
headers: {
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36'
}
},
logo: function (context) {
return context.channel.logo
},
parser: function (context) {
const programs = []
const items = parseItems(context.content)
items.forEach(item => {
programs.push({
title: item.title,
start: parseStart(item),
stop: parseStop(item),
description: item.description,
image: parseImage(item),
sub_title: item.subtitle
})
})
return programs
}
}
function parseItems(content) {
if (content != '') {
const data = JSON.parse(content)
return !data || !data.channel || !Array.isArray(data.channel.item) ? [] : data.channel.item
} else {
return []
}
}
function parseStart(item) {
return dayjs.unix(parseInt(item.pubDate) / 1000)
}
function parseStop(item) {
return dayjs.unix(parseInt(item.endDate) / 1000)
}
function parseImage(item) {
return 'https://www.nhk.or.jp' + item.thumbnail
}
const dayjs = require('dayjs')
module.exports = {
site: 'www3.nhk.or.jp',
days: 5,
lang: 'en',
delay: 5000,
url: function ({ date }) {
return `https://nwapi.nhk.jp/nhkworld/epg/v7b/world/s${date.unix() * 1000}-e${
date.add(1, 'd').unix() * 1000
}.json`
},
request: {
method: 'GET',
timeout: 5000,
cache: { ttl: 60 * 1000 },
headers: {
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36'
}
},
logo: function (context) {
return context.channel.logo
},
parser: function (context) {
const programs = []
const items = parseItems(context.content)
items.forEach(item => {
programs.push({
title: item.title,
start: parseStart(item),
stop: parseStop(item),
description: item.description,
image: parseImage(item),
sub_title: item.subtitle
})
})
return programs
}
}
function parseItems(content) {
if (content != '') {
const data = JSON.parse(content)
return !data || !data.channel || !Array.isArray(data.channel.item) ? [] : data.channel.item
} else {
return []
}
}
function parseStart(item) {
return dayjs.unix(parseInt(item.pubDate) / 1000)
}
function parseStop(item) {
return dayjs.unix(parseInt(item.endDate) / 1000)
}
function parseImage(item) {
return 'https://www.nhk.or.jp' + item.thumbnail
}
+43 -43
View File
@@ -1,43 +1,43 @@
const { url, parser } = require('./www3.nhk.or.jp.config.js')
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
dayjs.extend(utc)
const date = dayjs.utc('2023-04-29', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '0',
xmltv_id: 'NHKWorldJapan.jp',
lang: 'en',
logo: 'https://www3.nhk.or.jp/nhkworld/common/site_images/nw_webapp_1024x1024.png'
}
it('can generate valid url', () => {
expect(url({ channel, date })).toBe(
'https://nwapi.nhk.jp/nhkworld/epg/v7b/world/s1682726400000-e1682812800000.json'
)
})
it('can parse response', () => {
const content =
'{"channel":{"item":[{"seriesId":"1007","airingId":"000","title":"NHK NEWSLINE","description":"NHK WORLD-JAPAN\'s flagship hourly news program delivers the latest world news, business and weather, with a focus on Japan and the rest of Asia.","link":"/nhkworld/en/news/","pubDate":"1682726400000","endDate":"1682727000000","vodReserved":false,"jstrm":"1","wstrm":"1","subtitle":"","content":"","content_clean":"","pgm_gr_id":"","thumbnail":"/nhkworld/upld/thumbnails/en/tv/regular_program/340aed63308aafd1178172abf6325231_large.jpg","thumbnail_s":"/nhkworld/upld/thumbnails/en/tv/regular_program/340aed63308aafd1178172abf6325231_small.jpg","showlist":"0","internal":"0","genre":{"TV":"11","Top":"","LC":""},"vod_id":"","vod_url":"","analytics":"[nhkworld]simul;NHK NEWSLINE;w02,001;1007-000-2023;2023-04-29T09:00:00+09:00"}]}}'
const results = parser({ content })
expect(results).toMatchObject([
{
title: 'NHK NEWSLINE',
start: dayjs(1682726400000),
stop: dayjs(1682727000000),
description:
"NHK WORLD-JAPAN's flagship hourly news program delivers the latest world news, business and weather, with a focus on Japan and the rest of Asia.",
image:
'https://www.nhk.or.jp/nhkworld/upld/thumbnails/en/tv/regular_program/340aed63308aafd1178172abf6325231_large.jpg',
sub_title: ''
}
])
})
it('can handle empty guide', () => {
const results = parser({ content: '' })
expect(results).toMatchObject([])
})
const { url, parser } = require('./www3.nhk.or.jp.config.js')
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
dayjs.extend(utc)
const date = dayjs.utc('2023-04-29', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '0',
xmltv_id: 'NHKWorldJapan.jp',
lang: 'en',
logo: 'https://www3.nhk.or.jp/nhkworld/common/site_images/nw_webapp_1024x1024.png'
}
it('can generate valid url', () => {
expect(url({ channel, date })).toBe(
'https://nwapi.nhk.jp/nhkworld/epg/v7b/world/s1682726400000-e1682812800000.json'
)
})
it('can parse response', () => {
const content =
'{"channel":{"item":[{"seriesId":"1007","airingId":"000","title":"NHK NEWSLINE","description":"NHK WORLD-JAPAN\'s flagship hourly news program delivers the latest world news, business and weather, with a focus on Japan and the rest of Asia.","link":"/nhkworld/en/news/","pubDate":"1682726400000","endDate":"1682727000000","vodReserved":false,"jstrm":"1","wstrm":"1","subtitle":"","content":"","content_clean":"","pgm_gr_id":"","thumbnail":"/nhkworld/upld/thumbnails/en/tv/regular_program/340aed63308aafd1178172abf6325231_large.jpg","thumbnail_s":"/nhkworld/upld/thumbnails/en/tv/regular_program/340aed63308aafd1178172abf6325231_small.jpg","showlist":"0","internal":"0","genre":{"TV":"11","Top":"","LC":""},"vod_id":"","vod_url":"","analytics":"[nhkworld]simul;NHK NEWSLINE;w02,001;1007-000-2023;2023-04-29T09:00:00+09:00"}]}}'
const results = parser({ content })
expect(results).toMatchObject([
{
title: 'NHK NEWSLINE',
start: dayjs(1682726400000),
stop: dayjs(1682727000000),
description:
"NHK WORLD-JAPAN's flagship hourly news program delivers the latest world news, business and weather, with a focus on Japan and the rest of Asia.",
image:
'https://www.nhk.or.jp/nhkworld/upld/thumbnails/en/tv/regular_program/340aed63308aafd1178172abf6325231_large.jpg',
sub_title: ''
}
])
})
it('can handle empty guide', () => {
const results = parser({ content: '' })
expect(results).toMatchObject([])
})