mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 21:45:02 +03:00
[common] fix google_search (close #2924)
This commit is contained in:
parent
0d5562497f
commit
62013d034f
@ -1807,20 +1807,10 @@ def google_search(url):
|
|||||||
url = 'https://www.google.com/search?tbm=vid&q=%s' % parse.quote(keywords)
|
url = 'https://www.google.com/search?tbm=vid&q=%s' % parse.quote(keywords)
|
||||||
page = get_content(url, headers=fake_headers)
|
page = get_content(url, headers=fake_headers)
|
||||||
videos = re.findall(
|
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:')
|
print('Best matched result:')
|
||||||
return(videos[0][0])
|
return(videos[0])
|
||||||
|
|
||||||
|
|
||||||
def url_to_module(url):
|
def url_to_module(url):
|
||||||
|
Loading…
Reference in New Issue
Block a user