3 # Copyright (C) 2020 RĂ©mi Denis-Courmont
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation; either version 2.1 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
28 def warning(self
, msg
):
32 sys
.stderr
.write(msg
+ '\n')
36 'extract_flat': 'in_playlist',
38 'youtube_include_dash_manifest': False,
41 dl
= youtube_dl
.YoutubeDL(opts
)
44 infos
= dl
.extract_info(url
, download
=False)
46 if 'entries' in infos
:
47 for entry
in infos
['entries']:
48 if 'ie_key' in entry
and entry
['ie_key']:
49 # Flat-extracted playlist entry
50 url
= 'ytdl:///?' + urllib
.parse
.urlencode(entry
)
53 print(json
.dumps(infos
))
55 def url_process(ie_url
):
58 'youtube_include_dash_manifest': False,
61 dl
= youtube_dl
.YoutubeDL(opts
)
63 # Rebuild the original IE entry
66 for p
in urllib
.parse
.parse_qsl(url
[9:]):
69 infos
= dl
.process_ie_result(entry
, download
=False)
70 print(json
.dumps(infos
))
74 if url
.startswith('ytdl:///?'):