Skip to content

Commit

Permalink
[common] fix google_search (close #2924)
Browse files Browse the repository at this point in the history
  • Loading branch information
soimort committed Apr 22, 2022
1 parent 0d55624 commit 62013d0
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/you_get/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1807,20 +1807,10 @@ def google_search(url):
url = 'https://www.google.com/search?tbm=vid&q=%s' % parse.quote(keywords)
page = get_content(url, headers=fake_headers)
videos = re.findall(
r'<a href="(https?://[^"]+)" onmousedown="[^"]+"><h3 class="[^"]*">([^<]+)<', page
r'(https://www\.youtube\.com/watch\?v=[\w-]+)', page
)
vdurs = re.findall(r'<span class="vdur[^"]*">([^<]+)<', page)
durs = [r1(r'(\d+:\d+)', unescape_html(dur)) for dur in vdurs]
print('Google Videos search:')
for v in zip(videos, durs):
print('- video: {} [{}]'.format(
unescape_html(v[0][1]),
v[1] if v[1] else '?'
))
print('# you-get %s' % log.sprint(v[0][0], log.UNDERLINE))
print()
print('Best matched result:')
return(videos[0][0])
return(videos[0])


def url_to_module(url):
Expand Down

0 comments on commit 62013d0

Please sign in to comment.