File tree Expand file tree Collapse file tree 2 files changed +13
-11
lines changed
packages/metascraper-video-provider Expand file tree Collapse file tree 2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change 17
17
},
18
18
"dependencies" : {
19
19
"@metascraper/helpers" : " ^3.11.8" ,
20
- "cheerio" : " ~1.0.0-rc.2" ,
21
20
"json-future" : " ~2.1.2" ,
22
21
"lodash" : " ~4.17.10" ,
23
22
"parse-domain" : " ~2.1.2" ,
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
+ const parseDomain = require ( 'parse-domain' )
3
4
const jsonFuture = require ( 'json-future' )
4
- const cheerio = require ( 'cheerio' )
5
- const got = require ( 'got' )
5
+ const youtubedl = require ( 'youtube-dl' )
6
+ const { promisify } = require ( 'util' )
7
+
8
+ const getExtractors = promisify ( youtubedl . getExtractors )
6
9
7
10
; ( async ( ) => {
8
- const { body } = await got ( 'https://rg3.github.io/youtube-dl/supportedsites.html' )
9
- const $ = cheerio . load ( body )
10
- const set = new Set ( )
11
+ const extractors = await getExtractors ( )
11
12
12
- $ ( 'li' ) . each ( function ( i , el ) {
13
- const domain = $ ( el ) . text ( ) . split ( ':' ) [ 0 ] . toLowerCase ( )
14
- set . add ( domain )
15
- } )
13
+ const providers = extractors . reduce ( ( set , extractor ) => {
14
+ const provider = extractor . split ( ':' ) [ 0 ] . toLowerCase ( )
15
+ const { domain = '' } = parseDomain ( provider ) || { }
16
+ set . add ( domain || provider )
17
+ return set
18
+ } , new Set ( ) )
16
19
17
- await jsonFuture . saveAsync ( 'providers.json' , Array . from ( set ) )
20
+ await jsonFuture . saveAsync ( 'providers.json' , Array . from ( providers ) )
18
21
} ) ( )
You can’t perform that action at this time.
0 commit comments