From ca2b76e8190d3eb5cc8f1c2dbf5dd124f7b88942 Mon Sep 17 00:00:00 2001 From: Nikhil Gupta Date: Fri, 16 Aug 2019 04:28:45 +0530 Subject: [PATCH] Added warning when content is not available in region --- youtube_dl/extractor/gaana.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/youtube_dl/extractor/gaana.py b/youtube_dl/extractor/gaana.py index 39ed32629..73ebe72ed 100644 --- a/youtube_dl/extractor/gaana.py +++ b/youtube_dl/extractor/gaana.py @@ -181,14 +181,23 @@ class GaanaIE(GaanaBaseIE): self._set_cookie(self._BASE_URL, 'PHPSESSID', 'val') webpage = self._download_webpage(url, video_id) + data = re.findall(r'id="parent-row-(?:song|album|artist|playlist)\d+">(.*?)', webpage) + if len(data): + data = self._parse_json(data[0], video_id) + + entries = [] matchobj = re.findall(r'class="parentnode sourcelist_\d+">(.*?)', webpage) matchobj = [self._parse_json(g, video_id) for g in matchobj] - entries = [] + if len(matchobj) > 1: for g in matchobj: entries.append(self._create_entry(g, g['id'])) - data = re.findall(r'id="parent-row-(?:album|artist|playlist)\d+">(.*?)', webpage) - data = self._parse_json(data[0], video_id) return self.playlist_result(entries, data['id'], data['title']) - else: + elif len(matchobj) == 1: return self._create_entry(matchobj[0], matchobj[0]['id']) + elif data and not matchobj: + return self._create_entry(data, data['id']) + else: + for mess in re.findall(r'(.*?)', webpage): + print("[WARNING]: %s" % mess) + print("Could not download this song.")