diff --git a/scripts/.gitignore b/scripts/.gitignore new file mode 100644 index 00000000..54295185 --- /dev/null +++ b/scripts/.gitignore @@ -0,0 +1 @@ +edit.js \ No newline at end of file diff --git a/sites/dsmart.com.tr/dsmart.com.tr.config.js b/sites/dsmart.com.tr/dsmart.com.tr.config.js index 33405ba1..21145960 100644 --- a/sites/dsmart.com.tr/dsmart.com.tr.config.js +++ b/sites/dsmart.com.tr/dsmart.com.tr.config.js @@ -9,21 +9,21 @@ module.exports = { }, site: 'dsmart.com.tr', url({ date, channel }) { - return `https://www.dsmart.com.tr/api/v1/public/epg/schedules?page=${ - channel.site_id - }&limit=1&day=${date.format('YYYY-MM-DD')}` - }, - logo({ content }) { - const data = JSON.parse(content) - if (!data || !data.data.channels.length) return null - const logoId = data.data.channels[0].logo + const [page] = channel.site_id.split('#') - return logoId ? `https://www.dsmart.com.tr/epg/images/0x50/${logoId}` : null + return `https://www.dsmart.com.tr/api/v1/public/epg/schedules?page=${page}&limit=1&day=${date.format( + 'YYYY-MM-DD' + )}` + }, + logo({ content, channel }) { + const data = parseContent(content, channel) + + return data && data.logo ? `https://www.dsmart.com.tr/epg/images/0x50/${data.logo}` : null }, parser: function ({ content, channel, date }) { let offset = -1 let programs = [] - const items = parseItems(content) + const items = parseItems(content, channel) items.forEach(item => { let start = parseStart(item, date) if (offset === -1 && start.hour() > 18) start = start.subtract(1, 'd') @@ -52,9 +52,16 @@ function parseStop(item, date) { return dayjs.utc(item.end_date).set('date', date.get('date')) } -function parseItems(content) { +function parseContent(content, channel) { const data = JSON.parse(content) - if (!data || !data.data.channels.length) return [] + if (!data || !data.data || !Array.isArray(data.data.channels)) return null + const [_, channelId] = channel.site_id.split('#') - return data.data.channels[0].schedule + return data.data.channels.find(i => i.ch_no == channelId) +} + +function parseItems(content, channel) { + const data = parseContent(content, channel) + + return data ? data.schedule : [] } diff --git a/sites/dsmart.com.tr/dsmart.com.tr.test.js b/sites/dsmart.com.tr/dsmart.com.tr.test.js index bcc31e8a..8e26ace5 100644 --- a/sites/dsmart.com.tr/dsmart.com.tr.test.js +++ b/sites/dsmart.com.tr/dsmart.com.tr.test.js @@ -9,21 +9,21 @@ dayjs.extend(utc) const date = dayjs.utc('2021-11-06', 'YYYY-MM-DD').startOf('d') const channel = { - site_id: '1', + site_id: '1#1', xmltv_id: 'MovieSmartPremium.tr' } const content = `{"meta": {"code": 200, "message": "OK"}, "data": {"total": 200, "channels": [{"rating": 3, "ch_id": 805, "logo": "59f97253cfef0b75f4723ded", "ch_no": 1, "is_hd": true, "genre": [1, 2], "packages": ["58cfc9c7e138237a591f9a61", "58cfc9c7e138237a591f9a62", "58cfc9c7e138237a591f9a5f", "58cfc9c7e138237a591f9a60"], "slug": "moviesmart-premium", "hd": true, "_id": "58d29bb0eefad3db9c606290", "order": 1, "channel_name": "MovieSmart Premium", "description": "", "schedule": [{"actor": "", "year": "2015", "id": "60488f69cfef0b15935d70d7", "subject": "Goosebumps: Canavarlar Firarda (Goosebumps) T\\u00fcr: Komedi - Macera Y\\u00f6netmen: Rob Letterman Oyuncular: Jack Black, Dylan Minnette, Odeya Rush", "audio_subtitles": 3, "start_date": "2021-11-03T21:15:00Z", "channel": "58d29bb0eefad3db9c606290", "description": "B\\u00fcy\\u00fck \\u015fehirden k\\u00fc\\u00e7\\u00fck bir kasabaya ta\\u015f\\u0131nd\\u0131\\u011f\\u0131 i\\u00e7in mutsuz olan Zach Cooper, ta\\u015f\\u0131nd\\u0131klar\\u0131 evin tam yan\\u0131ndaki evde ya\\u015fayan g\\u00fczel k\\u0131z Hannah ile kar\\u015f\\u0131la\\u015f\\u0131p, Champ ile de k\\u0131sa s\\u00fcrede arkada\\u015f olunca yeni bir hayat i\\u00e7in umutlan\\u0131r. Ancak Zach, Hannah'n\\u0131n gizemli babas\\u0131n\\u0131n Goosebumps kitaplar\\u0131n\\u0131n yazar\\u0131, R.L. Stine oldu\\u011funu \\u00f6\\u011frendi\\u011finde, olaylar\\u0131n normal gitmeyece\\u011fini anlar. (Dil:T\\u00fcrk\\u00e7e/Orijinal - Altyaz\\u0131:T\\u00fcrk\\u00e7e/\\u0130ngilizce)", "director": "", "end_date": "2021-11-03T23:55:00Z", "genre": "sinema/genel", "program_name": "Goosebumps: Canavarlar Firarda", "day": "2021-11-05T21:00:00Z", "episode": "", "screen_violence": 4, "_id": "6185a3f6cfef0b1593e44e63", "duration": "1:40:00"},{"actor": "", "year": "2015", "id": "60488f69cfef0b15935d70d7", "subject": "Goosebumps: Canavarlar Firarda (Goosebumps) T\\u00fcr: Komedi - Macera Y\\u00f6netmen: Rob Letterman Oyuncular: Jack Black, Dylan Minnette, Odeya Rush", "audio_subtitles": 3, "start_date": "2021-11-03T23:55:00Z", "channel": "58d29bb0eefad3db9c606290", "description": "B\\u00fcy\\u00fck \\u015fehirden k\\u00fc\\u00e7\\u00fck bir kasabaya ta\\u015f\\u0131nd\\u0131\\u011f\\u0131 i\\u00e7in mutsuz olan Zach Cooper, ta\\u015f\\u0131nd\\u0131klar\\u0131 evin tam yan\\u0131ndaki evde ya\\u015fayan g\\u00fczel k\\u0131z Hannah ile kar\\u015f\\u0131la\\u015f\\u0131p, Champ ile de k\\u0131sa s\\u00fcrede arkada\\u015f olunca yeni bir hayat i\\u00e7in umutlan\\u0131r. Ancak Zach, Hannah'n\\u0131n gizemli babas\\u0131n\\u0131n Goosebumps kitaplar\\u0131n\\u0131n yazar\\u0131, R.L. Stine oldu\\u011funu \\u00f6\\u011frendi\\u011finde, olaylar\\u0131n normal gitmeyece\\u011fini anlar. (Dil:T\\u00fcrk\\u00e7e/Orijinal - Altyaz\\u0131:T\\u00fcrk\\u00e7e/\\u0130ngilizce)", "director": "", "end_date": "2021-11-03T01:55:00Z", "genre": "sinema/genel", "program_name": "Goosebumps: Canavarlar Firarda", "day": "2021-11-05T21:00:00Z", "episode": "", "screen_violence": 4, "_id": "6185a3f6cfef0b1593e44e63", "duration": "1:40:00"}]}]}}` it('can generate valid url', () => { - const result = url({ date, channel }) - expect(result).toBe( + expect(url({ date, channel })).toBe( 'https://www.dsmart.com.tr/api/v1/public/epg/schedules?page=1&limit=1&day=2021-11-06' ) }) it('can get logo url', () => { - const result = logo({ content }) - expect(result).toBe('https://www.dsmart.com.tr/epg/images/0x50/59f97253cfef0b75f4723ded') + expect(logo({ content, channel })).toBe( + 'https://www.dsmart.com.tr/epg/images/0x50/59f97253cfef0b75f4723ded' + ) }) it('can parse response', () => { diff --git a/sites/dsmart.com.tr/dsmart.com.tr_tr.channels.xml b/sites/dsmart.com.tr/dsmart.com.tr_tr.channels.xml index 0cb4c257..e1d3b87f 100644 --- a/sites/dsmart.com.tr/dsmart.com.tr_tr.channels.xml +++ b/sites/dsmart.com.tr/dsmart.com.tr_tr.channels.xml @@ -1,105 +1,100 @@ - - - - 24 Kitchen Türkiye - 24 TV - 360 - A Haber - A News - A Spor - ATV Türkiye - Baby TV Europe - BBC Earth Türkiye - BBC World News Europe - BBN Türk - Beyaz TV - Bloomberg HT - Boomerang Türkiye - Cartoon Network Türkiye - CNN International Europe - CNN Türk - Çocuk Smart - Da Vinci - Discovery Channel Türkiye - Discovery Science Türkiye - Disney Channel Türkiye - Disney Junior Türkiye & Polska - Diyanet TV - DiziSmart Max - DiziSmart Premium - DMAX Türkiye - DocuBox HD - Euro D - Eurosport 1 - Eurosport 2 - FashionTV HD Europe - Fast & FunBox HD - FB TV - FightBox HD - FilmBox Türkiye - Flash TV - Fox Crime Türkiye - Fox Türkiye - FX Türkiye - Haber Global - Habertürk - Insight HD - Kanal 7 - Kanal D - Love Nature - MovieSmart Classic - MovieSmart Premium - MovieSmart Premium 2 - MovieSmart Türk - National Geographic Türkiye - National Geographic Wild Türkiye - NBA TV - NTV - Number 1 Türk - Number 1 TV - Power TV - Show TV - Sinema 2 - Sinema 1001 - Sinema 1002 - Sinema Aile - Sinema Aile 2 - Sinema Aksiyon - Sinema Aksiyon 2 - Sinema Komedi - Sinema Komedi 2 - Sinema TV - Spor Smart - Spor Smart 2 - Sports TV - S Sport - S Sport 2 - Star TV - Stingray Naturescape - Tele 1 - Teve 2 - TGRT Haber - The History Channel Turkey - TLC Türkiye - Trace Urban - TRT 1 - TRT 2 - TRT 4K - TRT Avaz - TRT Belgesel - TRT Haber - TRT Kurdî - TRT Müzik - TRT Spor Yildiz - TRT Türk - TV 4 - TV 8 - TV 8.5 - TV 100 - TV Net - UçanKus TV - Ülke TV - Vav TV - Viasat History HD - - \ No newline at end of file + + + + 24 Kitchen Türkiye + 24 TV + 360 + A Haber + A Spor + ATV Türkiye + Baby TV Europe + BBC Earth Türkiye + BBC World News Europe + BBN Türk + Beyaz TV + Bloomberg HT + Boomerang Türkiye + Cartoon Network Türkiye + CNN International Europe + Çocuk Smart + Da Vinci + Discovery Channel Türkiye + Discovery Science Türkiye + Disney Channel Türkiye + Disney Junior Türkiye & Polska + Diyanet TV + DiziSmart Max + DiziSmart Premium + DMAX Türkiye + DocuBox HD + Eurosport 1 + Eurosport 2 + FashionTV HD Europe + Fast & FunBox HD + FB TV + FightBox HD + FilmBox Türkiye + Flash TV + Fox Crime Türkiye + Fox Türkiye + FX Türkiye + Haber Global + Habertürk + Insight HD + Kanal 7 + Kanal D + Love Nature + MovieSmart Classic + MovieSmart Premium + MovieSmart Premium 2 + MovieSmart Türk + National Geographic Türkiye + National Geographic Wild Türkiye + NBA TV + NTV + Number 1 Türk + Number 1 TV + Power TV + Show TV + Sinema 2 + Sinema 1001 + Sinema 1002 + Sinema Aile + Sinema Aile 2 + Sinema Aksiyon + Sinema Aksiyon 2 + Sinema Komedi + Sinema Komedi 2 + Sinema TV + Spor Smart + Spor Smart 2 + Sports TV + S Sport + S Sport 2 + Star TV + Stingray Naturescape + Tele 1 + Teve 2 + TGRT Haber + The History Channel Turkey + TLC Türkiye + Trace Urban + TRT 1 + TRT 2 + TRT Avaz + TRT Belgesel + TRT Haber + TRT Müzik + TRT Spor Yildiz + TRT Türk + TV 4 + TV 8 + TV 8.5 + TV 100 + TV Net + UçanKus TV + Ülke TV + Vav TV + Viasat History HD + + diff --git a/sites/tvtv.us/.gitignore b/sites/tvtv.us/.gitignore index 047766eb..02900957 100644 --- a/sites/tvtv.us/.gitignore +++ b/sites/tvtv.us/.gitignore @@ -1,2 +1 @@ -*.crawler.js -*.update.js \ No newline at end of file +*.crawler.js \ No newline at end of file