mirror of
https://github.com/iptv-org/epg
synced 2025-12-16 10:26:41 -05:00
Replace LF line endings with CRLF
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
# v3.myafn.dodmedia.osd.mil
|
||||
|
||||
https://v3.myafn.dodmedia.osd.mil/
|
||||
|
||||
### Download the guide
|
||||
|
||||
```sh
|
||||
npm run grab --- --site=v3.myafn.dodmedia.osd.mil
|
||||
```
|
||||
|
||||
### Update channel list
|
||||
|
||||
```sh
|
||||
npm run channels:parse --- --config=./sites/v3.myafn.dodmedia.osd.mil/v3.myafn.dodmedia.osd.mil.config.js --output=./sites/v3.myafn.dodmedia.osd.mil/v3.myafn.dodmedia.osd.mil.channels.xml
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
```sh
|
||||
npm test --- v3.myafn.dodmedia.osd.mil
|
||||
```
|
||||
# v3.myafn.dodmedia.osd.mil
|
||||
|
||||
https://v3.myafn.dodmedia.osd.mil/
|
||||
|
||||
### Download the guide
|
||||
|
||||
```sh
|
||||
npm run grab --- --site=v3.myafn.dodmedia.osd.mil
|
||||
```
|
||||
|
||||
### Update channel list
|
||||
|
||||
```sh
|
||||
npm run channels:parse --- --config=./sites/v3.myafn.dodmedia.osd.mil/v3.myafn.dodmedia.osd.mil.config.js --output=./sites/v3.myafn.dodmedia.osd.mil/v3.myafn.dodmedia.osd.mil.channels.xml
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
```sh
|
||||
npm test --- v3.myafn.dodmedia.osd.mil
|
||||
```
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<channels>
|
||||
<channel site="v3.myafn.dodmedia.osd.mil" lang="en" xmltv_id="AFNFamily.us" site_id="9">AFN|pulse</channel>
|
||||
<channel site="v3.myafn.dodmedia.osd.mil" lang="en" xmltv_id="AFNMovie.us" site_id="10">AFN|movie</channel>
|
||||
<channel site="v3.myafn.dodmedia.osd.mil" lang="en" xmltv_id="AFNNews.us" site_id="5">AFN|news</channel>
|
||||
<channel site="v3.myafn.dodmedia.osd.mil" lang="en" xmltv_id="AFNPrimeAtlantic.us" site_id="2">AFN|prime Atlantic</channel>
|
||||
<channel site="v3.myafn.dodmedia.osd.mil" lang="en" xmltv_id="AFNPrimePacific.us" site_id="4">AFN|prime Pacific</channel>
|
||||
<channel site="v3.myafn.dodmedia.osd.mil" lang="en" xmltv_id="AFNSpectrum.us" site_id="3">AFN|spectrum</channel>
|
||||
<channel site="v3.myafn.dodmedia.osd.mil" lang="en" xmltv_id="AFNSports2.us" site_id="6">AFN|sports2</channel>
|
||||
<channel site="v3.myafn.dodmedia.osd.mil" lang="en" xmltv_id="AFNSports.us" site_id="1">AFN|sports</channel>
|
||||
</channels>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<channels>
|
||||
<channel site="v3.myafn.dodmedia.osd.mil" lang="en" xmltv_id="AFNFamily.us" site_id="9">AFN|pulse</channel>
|
||||
<channel site="v3.myafn.dodmedia.osd.mil" lang="en" xmltv_id="AFNMovie.us" site_id="10">AFN|movie</channel>
|
||||
<channel site="v3.myafn.dodmedia.osd.mil" lang="en" xmltv_id="AFNNews.us" site_id="5">AFN|news</channel>
|
||||
<channel site="v3.myafn.dodmedia.osd.mil" lang="en" xmltv_id="AFNPrimeAtlantic.us" site_id="2">AFN|prime Atlantic</channel>
|
||||
<channel site="v3.myafn.dodmedia.osd.mil" lang="en" xmltv_id="AFNPrimePacific.us" site_id="4">AFN|prime Pacific</channel>
|
||||
<channel site="v3.myafn.dodmedia.osd.mil" lang="en" xmltv_id="AFNSpectrum.us" site_id="3">AFN|spectrum</channel>
|
||||
<channel site="v3.myafn.dodmedia.osd.mil" lang="en" xmltv_id="AFNSports2.us" site_id="6">AFN|sports2</channel>
|
||||
<channel site="v3.myafn.dodmedia.osd.mil" lang="en" xmltv_id="AFNSports.us" site_id="1">AFN|sports</channel>
|
||||
</channels>
|
||||
|
||||
@@ -1,76 +1,76 @@
|
||||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
module.exports = {
|
||||
site: 'v3.myafn.dodmedia.osd.mil',
|
||||
days: 2,
|
||||
request: {
|
||||
cache: {
|
||||
ttl: 60 * 60 * 1000 // 1 hour
|
||||
}
|
||||
},
|
||||
url: function ({ date }) {
|
||||
return `https://v3.myafn.dodmedia.osd.mil/api/json/32/${date.format(
|
||||
'YYYY-MM-DD'
|
||||
)}@0000/${date.format('YYYY-MM-DD')}@2359/schedule.json`
|
||||
},
|
||||
parser: function ({ content, date, channel }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
const start = parseStart(item, date)
|
||||
const stop = start.add(item.o, 'm')
|
||||
programs.push({
|
||||
title: item.h,
|
||||
sub_title: item.i,
|
||||
description: item.l,
|
||||
rating: parseRating(item),
|
||||
category: parseCategory(item),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const data = await axios
|
||||
.get('https://v3.myafn.dodmedia.osd.mil/api/json/32/channels.json')
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
return data.map(item => ({
|
||||
site_id: item.Channel,
|
||||
name: item.Title
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.utc(item.e, 'YYYY,M,D,H,m,s,0').add(1, 'month')
|
||||
}
|
||||
|
||||
function parseCategory(item) {
|
||||
return item.m ? item.m.split(',') : []
|
||||
}
|
||||
|
||||
function parseRating(item) {
|
||||
return item.j
|
||||
? {
|
||||
system: 'MPA',
|
||||
value: item.j
|
||||
}
|
||||
: null
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
const items = JSON.parse(content)
|
||||
if (!Array.isArray(items)) return []
|
||||
|
||||
return items.filter(i => i.b == channel.site_id)
|
||||
}
|
||||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
module.exports = {
|
||||
site: 'v3.myafn.dodmedia.osd.mil',
|
||||
days: 2,
|
||||
request: {
|
||||
cache: {
|
||||
ttl: 60 * 60 * 1000 // 1 hour
|
||||
}
|
||||
},
|
||||
url: function ({ date }) {
|
||||
return `https://v3.myafn.dodmedia.osd.mil/api/json/32/${date.format(
|
||||
'YYYY-MM-DD'
|
||||
)}@0000/${date.format('YYYY-MM-DD')}@2359/schedule.json`
|
||||
},
|
||||
parser: function ({ content, date, channel }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
const start = parseStart(item, date)
|
||||
const stop = start.add(item.o, 'm')
|
||||
programs.push({
|
||||
title: item.h,
|
||||
sub_title: item.i,
|
||||
description: item.l,
|
||||
rating: parseRating(item),
|
||||
category: parseCategory(item),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const data = await axios
|
||||
.get('https://v3.myafn.dodmedia.osd.mil/api/json/32/channels.json')
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
return data.map(item => ({
|
||||
site_id: item.Channel,
|
||||
name: item.Title
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.utc(item.e, 'YYYY,M,D,H,m,s,0').add(1, 'month')
|
||||
}
|
||||
|
||||
function parseCategory(item) {
|
||||
return item.m ? item.m.split(',') : []
|
||||
}
|
||||
|
||||
function parseRating(item) {
|
||||
return item.j
|
||||
? {
|
||||
system: 'MPA',
|
||||
value: item.j
|
||||
}
|
||||
: null
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
const items = JSON.parse(content)
|
||||
if (!Array.isArray(items)) return []
|
||||
|
||||
return items.filter(i => i.b == channel.site_id)
|
||||
}
|
||||
|
||||
@@ -1,55 +1,55 @@
|
||||
const { parser, url } = require('./v3.myafn.dodmedia.osd.mil.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-10-03', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '2',
|
||||
xmltv_id: 'AFNPrimeAtlantic.us'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ date })).toBe(
|
||||
'https://v3.myafn.dodmedia.osd.mil/api/json/32/2022-10-03@0000/2022-10-03@2359/schedule.json'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content =
|
||||
'[{"a":566,"b":2,"c":"2022,9,3,3,0,0,0","d":"2022,9,3,4,0,0,0","e":"2022,9,3,3,0,0,0","f":"2022,9,3,4,0,0,0","g":60,"h":"This Week with George Stephanopoulos (ABC)","i":"Episode Title","j":"TV-14","k":false,"l":"Former Clinton White House staffer and current co-anchor of ABC\'s weekday morning news show \\"\\"Good Morning America,\\"\\" George Stephanopoulos and co-anchors Martha Raddatz and Jonathan Karl offer a look at current events with a focus on the politics of the day. Each week\'s show includes interviews with top newsmakers (including some of the nation\'s top political leaders) as well as a roundtable discussion, usually featuring journalists from ABC and other news organizations, of the week\'s happenings. Since 2008, the program has broadcast from a studio at the Newseum in Washington, D.C.","m":"News,Politics,Public affairs,Talk","n":694284445,"o":60,"p":20,"q":true,"r":694285705,"s":null}]'
|
||||
const result = parser({ content, date, channel }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-10-03T03:00:00.000Z',
|
||||
stop: '2022-10-03T04:00:00.000Z',
|
||||
title: 'This Week with George Stephanopoulos (ABC)',
|
||||
sub_title: 'Episode Title',
|
||||
description:
|
||||
'Former Clinton White House staffer and current co-anchor of ABC\'s weekday morning news show ""Good Morning America,"" George Stephanopoulos and co-anchors Martha Raddatz and Jonathan Karl offer a look at current events with a focus on the politics of the day. Each week\'s show includes interviews with top newsmakers (including some of the nation\'s top political leaders) as well as a roundtable discussion, usually featuring journalists from ABC and other news organizations, of the week\'s happenings. Since 2008, the program has broadcast from a studio at the Newseum in Washington, D.C.',
|
||||
category: ['News', 'Politics', 'Public affairs', 'Talk'],
|
||||
rating: {
|
||||
system: 'MPA',
|
||||
value: 'TV-14'
|
||||
}
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: `{
|
||||
"Message": "An error has occurred."
|
||||
}`,
|
||||
date,
|
||||
channel
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
const { parser, url } = require('./v3.myafn.dodmedia.osd.mil.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-10-03', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '2',
|
||||
xmltv_id: 'AFNPrimeAtlantic.us'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ date })).toBe(
|
||||
'https://v3.myafn.dodmedia.osd.mil/api/json/32/2022-10-03@0000/2022-10-03@2359/schedule.json'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content =
|
||||
'[{"a":566,"b":2,"c":"2022,9,3,3,0,0,0","d":"2022,9,3,4,0,0,0","e":"2022,9,3,3,0,0,0","f":"2022,9,3,4,0,0,0","g":60,"h":"This Week with George Stephanopoulos (ABC)","i":"Episode Title","j":"TV-14","k":false,"l":"Former Clinton White House staffer and current co-anchor of ABC\'s weekday morning news show \\"\\"Good Morning America,\\"\\" George Stephanopoulos and co-anchors Martha Raddatz and Jonathan Karl offer a look at current events with a focus on the politics of the day. Each week\'s show includes interviews with top newsmakers (including some of the nation\'s top political leaders) as well as a roundtable discussion, usually featuring journalists from ABC and other news organizations, of the week\'s happenings. Since 2008, the program has broadcast from a studio at the Newseum in Washington, D.C.","m":"News,Politics,Public affairs,Talk","n":694284445,"o":60,"p":20,"q":true,"r":694285705,"s":null}]'
|
||||
const result = parser({ content, date, channel }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2022-10-03T03:00:00.000Z',
|
||||
stop: '2022-10-03T04:00:00.000Z',
|
||||
title: 'This Week with George Stephanopoulos (ABC)',
|
||||
sub_title: 'Episode Title',
|
||||
description:
|
||||
'Former Clinton White House staffer and current co-anchor of ABC\'s weekday morning news show ""Good Morning America,"" George Stephanopoulos and co-anchors Martha Raddatz and Jonathan Karl offer a look at current events with a focus on the politics of the day. Each week\'s show includes interviews with top newsmakers (including some of the nation\'s top political leaders) as well as a roundtable discussion, usually featuring journalists from ABC and other news organizations, of the week\'s happenings. Since 2008, the program has broadcast from a studio at the Newseum in Washington, D.C.',
|
||||
category: ['News', 'Politics', 'Public affairs', 'Talk'],
|
||||
rating: {
|
||||
system: 'MPA',
|
||||
value: 'TV-14'
|
||||
}
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
content: `{
|
||||
"Message": "An error has occurred."
|
||||
}`,
|
||||
date,
|
||||
channel
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user