Skip to content
This repository was archived by the owner on Mar 21, 2023. It is now read-only.

Commit 2baec5f

Browse files
fix: #37 use set pages command to config how many search result pages to show
1 parent 42f6496 commit 2baec5f

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

mps_youtube/commands/search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def search(term):
298298

299299
msg = "Search results for %s%s%s" % (c.y, term, c.w)
300300
failmsg = "Found nothing for %s%s%s" % (c.y, term, c.w)
301-
wdata = pafy.video_search(term)
301+
wdata = pafy.search_videos(term, int(config.PAGES.get))
302302
_display_search_results(term, wdata, msg, failmsg)
303303

304304

mps_youtube/config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,7 @@ class _Config:
340340
allowed_values="auto webm m4a".split()),
341341
ConfigItem("video_format", "auto",
342342
allowed_values="auto webm mp4 3gp".split()),
343-
# ConfigItem("api_key", "",
344-
# check_fn=check_api_key),
343+
ConfigItem("pages", 3, minval=1, maxval=100),
345344
ConfigItem("autoplay", False),
346345
ConfigItem("set_title", True),
347346
ConfigItem("mpris", not mswin),

mps_youtube/pafy.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,20 @@ def download_video(ytid, folder):
4444
ydl.download('https://www.youtube.com/watch?v=%s' % ytid)
4545
return True
4646

47-
def video_search(query):
47+
def search_videos(query, pages):
4848

4949
'''
5050
Given a keyword / query this function will return youtube video results against those keywords / query
5151
'''
5252

5353
videosSearch = VideosSearch(query, limit=50)
5454
wdata = videosSearch.result()['result']
55+
for i in range(pages-1):
56+
videosSearch.next()
57+
wdata.extend(videosSearch.result()['result'])
5558
return wdata
5659

60+
5761
def channel_search(query):
5862

5963
'''

0 commit comments

Comments
 (0)