Merge pull request #1967 from iptv-org/fix-plex.tv

Fix plex.tv
This commit is contained in:
ajanes3 authored and GitHub committed 2023-02-06 11:06:22 -05:00
commit c9e1a063ab
3 files changed
+28 -36

No files matched your search

+1 -1
View File
@@ -1 +1 @@
{"MediaContainer":{"offset":0,"totalSize":10,"identifier":"tv.plex.provider.epg","size":10,"Metadata":[{"art":"https://metadata-static.plex.tv/4/gracenote/40b523ad60464f8232f93f861c161384.jpg","guid":"plex://movie/5fc68837051be1002d6f88e7","key":"/library/metadata/5fc68837051be1002d6f88e7","ratingKey":"5fc68837051be1002d6f88e7","summary":"Conjoined twins Daisy and Violet Hilton were born in 1908, then were sold to a carnival sideshow as babies. They became huge stars of Vaudeville but never earned a penny until they sued for freedom in 1936.","type":"movie","thumb":"https://metadata-static.plex.tv/2/gracenote/2384b632d3af4e5706b27c774926aa39.jpg","addedAt":1606846519,"duration":5400000,"userState":false,"title":"Bound by Flesh","skipParent":true,"originallyAvailableAt":"2012-01-02T00:00:00Z","year":2012,"Image":[{"alt":"Bound by Flesh","type":"coverArt","url":"https://metadata-static.plex.tv/9/gracenote/9fa0ce753d965808f999199669e4dfb0.jpg"},{"alt":"Bound by Flesh","type":"coverPoster","url":"https://metadata-static.plex.tv/2/gracenote/2384b632d3af4e5706b27c774926aa39.jpg"},{"alt":"Bound by Flesh","type":"snapshot","url":"https://metadata-static.plex.tv/4/gracenote/40b523ad60464f8232f93f861c161384.jpg"}],"Genre":[{"filter":"genre=6006cc18610ee2002c74f2fd","id":"6006cc18610ee2002c74f2fd","key":"/library/sections/home/all?genre=6006cc18610ee2002c74f2fd","ratingKey":"genre_6006cc18610ee2002c74f2fd","slug":"documentary","tag":"Documentary","type":"directory","context":"tag.genre"},{"filter":"genre=620143f98578b9238e1cdb89","id":"620143f98578b9238e1cdb89","key":"/library/sections/home/all?genre=620143f98578b9238e1cdb89","ratingKey":"genre_620143f98578b9238e1cdb89","slug":"movies","tag":"Movies","type":"directory","context":"tag.genre"}],"Media":[{"beginsAt":1668467040,"duration":6180000,"endsAt":1668473220,"id":"635f6d24b24bc1f730786927","onAir":false,"premiere":false,"videoResolution":"720","origin":"livetv"}]},{"art":"https://metadata-static.plex.tv/0/gracenote/0fbf37f6079fff1942128d687249ee5a.jpg","guid":"plex://movie/5fc687a86b022a002d6d170e","key":"/library/metadata/5fc687a86b022a002d6d170e","ratingKey":"5fc687a86b022a002d6d170e","summary":"Two entomologists (Sidse Babett Knudsen, Chiara D'Anna) play ritual games of dominance and subservience.","type":"movie","thumb":"https://metadata-static.plex.tv/b/gracenote/b30630b28b0d9a821f8e96b2751d0200.jpg","addedAt":1606846376,"duration":6360000,"userState":false,"title":"The Duke of Burgundy","skipParent":true,"originallyAvailableAt":"2014-01-02T00:00:00Z","year":2014,"Image":[{"alt":"The Duke of Burgundy","type":"background","url":"https://metadata-static.plex.tv/0/gracenote/0fbf37f6079fff1942128d687249ee5a.jpg"},{"alt":"The Duke of Burgundy","type":"coverArt","url":"https://metadata-static.plex.tv/b/gracenote/befa7029194a4d08a98c13f96afd2b87.jpg"},{"alt":"The Duke of Burgundy","type":"coverPoster","url":"https://metadata-static.plex.tv/b/gracenote/b30630b28b0d9a821f8e96b2751d0200.jpg"},{"alt":"The Duke of Burgundy","type":"coverSquare","url":"https://metadata-static.plex.tv/7/gracenote/7a4da73909981dae38be8eb42f0ed84b.jpg"},{"alt":"The Duke of Burgundy","type":"snapshot","url":"https://metadata-static.plex.tv/3/gracenote/3418f9ef1fee9bd214c69c39f9cc1296.jpg"}],"Genre":[{"filter":"genre=6006cc18610ee2002c74f2fe","id":"6006cc18610ee2002c74f2fe","key":"/library/sections/home/all?genre=6006cc18610ee2002c74f2fe","ratingKey":"genre_6006cc18610ee2002c74f2fe","slug":"drama","tag":"Drama","type":"directory","context":"tag.genre"},{"filter":"genre=6006cc1b610ee2002c74f359","id":"6006cc1b610ee2002c74f359","key":"/library/sections/home/all?genre=6006cc1b610ee2002c74f359","ratingKey":"genre_6006cc1b610ee2002c74f359","slug":"gaylesbian","tag":"LGBTQ+","originalTag":"LGBTQ","type":"directory","context":"tag.genre"},{"filter":"genre=620143f98578b9238e1cdb89","id":"620143f98578b9238e1cdb89","key":"/library/sections/home/all?genre=620143f98578b9238e1cdb89","ratingKey":"genre_620143f98578b9238e1cdb89","slug":"movies","tag":"Movies","type":"directory","context":"tag.genre"}],"Media":[{"beginsAt":1668473220,"duration":7080000,"endsAt":1668480300,"id":"6360f74a667be51125040ef8","onAir":false,"premiere":false,"videoResolution":"720","origin":"livetv"}]},{"art":"https://metadata-static.plex.tv/f/gracenote/f15e34a562fd16d018a7f16c6379dafa.jpg","guid":"plex://movie/5fc68f1b678e02002ec2f94d","key":"/library/metadata/5fc68f1b678e02002ec2f94d","ratingKey":"5fc68f1b678e02002ec2f94d","summary":"Two brothers create a product that is supposed to revolutionize law enforcement. As their company grows, they make decisions that have a lasting impact on their business and the public.","type":"movie","thumb":"https://metadata-static.plex.tv/4/gracenote/4b0dbb029595b3b08f7e7da7b7798015.jpg","addedAt":1606848283,"duration":6000000,"userState":false,"title":"Killing Them Safely","skipParent":true,"originallyAvailableAt":"2015-01-02T00:00:00Z","year":2015,"Image":[{"alt":"Killing Them Safely","type":"coLine truncated
{"MediaContainer":{"offset":0,"totalSize":14,"identifier":"tv.plex.provider.epg","size":14,"Metadata":[{"art":"https://provider-static.plex.tv/epg/images/ott_channels/arts/darkmatter-tv-about.jpg","guid":"plex://movie/63b81350d2875f8fec640306","key":"/library/metadata/63b81350d2875f8fec640306","ratingKey":"63b81350d2875f8fec640306","summary":"N/A","type":"movie","thumb":"https://provider-static.plex.tv/epg/images/thumbnails/darkmatter-tv-fallback.jpg","duration":920000,"userState":false,"title":"You're watching DMTV_animated_20sec","skipParent":true,"Image":[{"alt":"You're watching DMTV_animated_20sec","type":"coverArt","url":"https://provider-static.plex.tv/epg/images/ott_channels/arts/darkmatter-tv-about.jpg"},{"alt":"You're watching DMTV_animated_20sec","type":"coverPoster","url":"https://provider-static.plex.tv/epg/images/thumbnails/darkmatter-tv-fallback.jpg"}],"Genre":[{"filter":"genre=620143f98578b9238e1cdb89","id":"620143f98578b9238e1cdb89","key":"/library/sections/home/all?genre=620143f98578b9238e1cdb89","ratingKey":"genre_620143f98578b9238e1cdb89","slug":"movies","tag":"Movies","type":"directory","context":"tag.genre"}],"Media":[{"beginsAt":1675607077,"duration":1307000,"endsAt":1675608384,"id":"63d665d2898017f0d6821795","onAir":false,"premiere":false,"videoResolution":"720","origin":"livetv"}]},{"art":"https://provider-static.plex.tv/epg/images/ott_channels/arts/darkmatter-tv-about.jpg","guid":"plex://movie/63b81350d2875f8fec640307","key":"/library/metadata/63b81350d2875f8fec640307","ratingKey":"63b81350d2875f8fec640307","summary":"N/A","type":"movie","thumb":"https://provider-static.plex.tv/epg/images/thumbnails/darkmatter-tv-fallback.jpg","duration":654000,"userState":false,"title":"You're watching DMTV_post-adslate bumper","skipParent":true,"Image":[{"alt":"You're watching DMTV_post-adslate bumper","type":"coverArt","url":"https://provider-static.plex.tv/epg/images/ott_channels/arts/darkmatter-tv-about.jpg"},{"alt":"You're watching DMTV_post-adslate bumper","type":"coverPoster","url":"https://provider-static.plex.tv/epg/images/thumbnails/darkmatter-tv-fallback.jpg"}],"Genre":[{"filter":"genre=620143f98578b9238e1cdb89","id":"620143f98578b9238e1cdb89","key":"/library/sections/home/all?genre=620143f98578b9238e1cdb89","ratingKey":"genre_620143f98578b9238e1cdb89","slug":"movies","tag":"Movies","type":"directory","context":"tag.genre"}],"Media":[{"beginsAt":1675608384,"duration":641000,"endsAt":1675609025,"id":"63d665d2898017f0d6821796","onAir":false,"premiere":false,"videoResolution":"720","origin":"livetv"},{"beginsAt":1675609025,"duration":1339000,"endsAt":1675610364,"id":"63d665d2898017f0d6821797","onAir":false,"premiere":false,"videoResolution":"720","origin":"livetv"}]},{"art":"http://d2rmfcv0bgsoe4.cloudfront.net/POSTER_169_chroniclesoftheghostlytribe.jpg","guid":"plex://movie/63cd2b524553a0b3e7c417ab","key":"/library/metadata/63cd2b524553a0b3e7c417ab","ratingKey":"63cd2b524553a0b3e7c417ab","summary":"A soldier is working in a snowcapped mountain when an explosion reveals bizarre fossils hidden deep in the caverns. What they discover next will change human history forever.","type":"movie","thumb":"https://provider-static.plex.tv/epg/images/thumbnails/darkmatter-tv-fallback.jpg","duration":1580000,"userState":false,"title":"Chronicles of the Ghostly Tribe","skipParent":true,"originallyAvailableAt":"2016-01-01T00:00:00Z","year":2016,"Image":[{"alt":"Chronicles of the Ghostly Tribe","type":"coverArt","url":"http://d2rmfcv0bgsoe4.cloudfront.net/POSTER_169_chroniclesoftheghostlytribe.jpg"},{"alt":"Chronicles of the Ghostly Tribe","type":"coverPoster","url":"https://provider-static.plex.tv/epg/images/thumbnails/darkmatter-tv-fallback.jpg"}],"Genre":[{"filter":"genre=620143f98578b9238e1cdb89","id":"620143f98578b9238e1cdb89","key":"/library/sections/home/all?genre=620143f98578b9238e1cdb89","ratingKey":"genre_620143f98578b9238e1cdb89","slug":"movies","tag":"Movies","type":"directory","context":"tag.genre"}],"Media":[{"beginsAt":1675610364,"duration":1580000,"endsAt":1675611944,"id":"63d665d2898017f0d6821798","onAir":false,"premiere":false,"videoResolution":"720","origin":"livetv"},{"beginsAt":1675611950,"duration":1293000,"endsAt":1675613237,"id":"63d665d2898017f0d6821799","onAir":false,"premiere":false,"videoResolution":"720","origin":"livetv"},{"beginsAt":1675613237,"duration":1428000,"endsAt":1675614665,"id":"63d665d2898017f0d682179a","onAir":false,"premiere":false,"videoResolution":"720","origin":"livetv"},{"beginsAt":1675614665,"duration":1486000,"endsAt":1675616151,"id":"63d665d2898017f0d682179b","onAir":false,"premiere":false,"videoResolution":"720","origin":"livetv"},{"beginsAt":1675616151,"duration":1157000,"endsAt":1675617308,"id":"63d665d2898017f0d682179c","onAir":false,"premiere":false,"videoResolution":"720","origin":"livetv"},{"beginsAt":1675617308,"duration":1782000,"endsAt":1675619090,"id":"63d665d2898017f0d682179d","onAir":false,"premiere":false,"videoResolution":"720","origin":"liveLine truncated
+16 -4
View File
@@ -65,14 +65,26 @@ function parseItems(content) {
const metadata = data.MediaContainer.Metadata
const items = []
metadata.forEach(item => {
item.Media.forEach(media => {
items.push({ ...item, ...media })
let segments = []
item.Media.sort(byTime).forEach((media, i) => {
let prevSegment = segments[segments.length - 1]
if (prevSegment && prevSegment.endsAt === media.beginsAt) {
prevSegment.endsAt = media.endsAt
} else {
segments.push(media)
}
})
segments.forEach(segment => {
items.push({ ...item, segments, beginsAt: segment.beginsAt, endsAt: segment.endsAt })
})
})
return items.sort((a, b) => {
return items.sort(byTime)
function byTime(a, b) {
if (a.beginsAt > b.beginsAt) return 1
if (a.beginsAt < b.beginsAt) return -1
return 0
})
}
}
+11 -31
View File
@@ -13,15 +13,15 @@ dayjs.extend(utc)
jest.mock('axios')
const date = dayjs.utc('2022-11-15', 'YYYY-MM-DD').startOf('d')
const date = dayjs.utc('2023-02-05', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '5e20b730f2f8d5003d739db7-5fc705eb052f6f002ef46057',
xmltv_id: 'IFCFilmsPicks.us'
site_id: '5e20b730f2f8d5003d739db7-5eea605674085f0040ddc7a6',
xmltv_id: 'DarkMatterTV.us'
}
it('can generate valid url', () => {
expect(url({ channel, date })).toBe(
'https://epg.provider.plex.tv/grid?channelGridKey=5fc705eb052f6f002ef46057&date=2022-11-15'
'https://epg.provider.plex.tv/grid?channelGridKey=5eea605674085f0040ddc7a6&date=2023-02-05'
)
})
@@ -40,35 +40,15 @@ it('can parse response', () => {
return p
})
expect(results.length).toBe(14)
// expect(results.length).toBe(15)
expect(results[0]).toMatchObject({
start: '2022-11-14T23:04:00.000Z',
stop: '2022-11-15T00:47:00.000Z',
title: 'Bound by Flesh',
start: '2023-02-04T23:31:14.000Z',
stop: '2023-02-05T01:10:45.000Z',
title: 'Violet & Daisy',
description:
'Conjoined twins Daisy and Violet Hilton were born in 1908, then were sold to a carnival sideshow as babies. They became huge stars of Vaudeville but never earned a penny until they sued for freedom in 1936.',
icon: 'https://metadata-static.plex.tv/4/gracenote/40b523ad60464f8232f93f861c161384.jpg',
categories: ['Documentary', 'Movies']
})
expect(results[10]).toMatchObject({
start: '2022-11-15T16:45:00.000Z',
stop: '2022-11-15T18:47:00.000Z',
title: 'Antiviral',
description:
"Syd has to unravel the mystery surrounding Hannah's death before a virus kills him.",
icon: 'https://metadata-static.plex.tv/5/gracenote/5ca8432a2e8fb2e8f8157ae142164ef7.jpg',
categories: ['Horror', 'Science fiction', 'Thriller', 'Movies']
})
expect(results[11]).toMatchObject({
start: '2022-11-15T18:47:00.000Z',
stop: '2022-11-15T20:36:00.000Z',
title: 'Cold Weather',
description:
'Armed with a few clues and an in-depth knowledge of Sherlock Holmes lore, an ice-factory worker (Cris Lankenau) leads his sister and a co-worker on a search for his missing former lover.',
icon: 'https://metadata-static.plex.tv/5/gracenote/5150185f3188dbefd10b5d388e8ba115.jpg',
categories: ['Comedy', 'Mystery', 'Movies']
'Two teenage assassins accept what they think will be a quick-and-easy job, until an unexpected target throws them off their plan.',
icon: 'https://provider-static.plex.tv/epg/images/ott_channels/arts/darkmatter-tv-about.jpg',
categories: ['Movies']
})
})