#!/usr/bin/env python
__all__ = ['google_download']
from ..common import *
import re
def google_download(url, output_dir = '.', merge = True, info_only = False):
# Percent-encoding Unicode URL
url = parse.quote(url, safe = ':/+%')
service = url.split('/')[2].split('.')[0]
if service == 'plus': # Google Plus
html = get_html(url)
html = parse.unquote(html).replace('\/', '/')
title = r1(r'
(.*)', html) or r1(r'(.*)\n', html) or r1(r' 1:
title = ".".join(title.split('.')[:-1])
docid = r1(r'"docid":"([^"]*)"', html)
request.install_opener(request.build_opener(request.HTTPCookieProcessor()))
request.urlopen(request.Request("https://docs.google.com/uc?id=%s&export=download" % docid))
real_url ="https://docs.google.com/uc?export=download&confirm=no_antivirus&id=%s" % docid
type, ext, size = url_info(real_url)
print_info(site_info, title, ext, size)
if not info_only:
download_urls([real_url], title, ext, size, output_dir, merge = merge)
site_info = "Google.com"
download = google_download
download_playlist = playlist_not_supported('google')