From 73742ef865e59384058e7cda36d3e7bc914f3f41 Mon Sep 17 00:00:00 2001 From: alexmercerind Date: Fri, 29 Jan 2021 22:45:18 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8D=20Removed=20accidential=20await=20?= =?UTF-8?q?from=20sync=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- youtubesearchpython/handlers/requesthandler.py | 12 ++++++------ youtubesearchpython/internal/search.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/youtubesearchpython/handlers/requesthandler.py b/youtubesearchpython/handlers/requesthandler.py index c683a9f..76fdc4f 100644 --- a/youtubesearchpython/handlers/requesthandler.py +++ b/youtubesearchpython/handlers/requesthandler.py @@ -40,17 +40,17 @@ def _makeRequest(self) -> None: def _parseSource(self) -> None: try: if not self.continuationKey: - responseContent = await self._getValue(self.response, contentPath) + responseContent = self._getValue(json.loads(self.response), contentPath) else: - responseContent = await self._getValue(self.response, continuationContentPath) + responseContent = self._getValue(json.loads(self.response), continuationContentPath) if responseContent: for element in responseContent: if itemSectionKey in element.keys(): - self.responseSource = await self._getValue(element, [itemSectionKey, 'contents']) + self.responseSource = self._getValue(element, [itemSectionKey, 'contents']) if continuationItemKey in element.keys(): - self.continuationKey = await self._getValue(element, continuationKeyPath) + self.continuationKey = self._getValue(element, continuationKeyPath) else: - self.responseSource = await self._getValue(self.response, fallbackContentPath) - self.continuationKey = await self._getValue(self.responseSource[-1], continuationKeyPath) + self.responseSource = self._getValue(json.loads(self.response), fallbackContentPath) + self.continuationKey = self._getValue(self.responseSource[-1], continuationKeyPath) except: raise Exception('ERROR: Could not parse YouTube response.') \ No newline at end of file diff --git a/youtubesearchpython/internal/search.py b/youtubesearchpython/internal/search.py index 01f22ee..fe2d6e8 100644 --- a/youtubesearchpython/internal/search.py +++ b/youtubesearchpython/internal/search.py @@ -67,10 +67,10 @@ def _getComponents(self, findVideos: bool, findChannels: bool, findPlaylists: bo for shelfElement in self._getShelfComponent(element)['elements']: self.resultComponents.append(self._getVideoComponent(shelfElement, shelfTitle = self.getShelfComponent(element)['title'])) if richItemKey in element.keys(): - richItemElement = await self._getValue(element, [richItemKey, 'content']) + richItemElement = self._getValue(element, [richItemKey, 'content']) ''' Initial fallback handling for VideosSearch ''' if videoElementKey in richItemElement.keys(): - videoComponent = await self._getVideoComponent(richItemElement) + videoComponent = self._getVideoComponent(richItemElement) self.resultComponents.append(videoComponent) if len(self.resultComponents) >= self.limit: break