patch regex for more links
This commit is contained in:
parent
4d964b6e29
commit
315108e7d1
|
|
@ -68,11 +68,11 @@ class GoogleDriveHelper:
|
|||
@staticmethod
|
||||
def getIdFromUrl(link: str):
|
||||
if "folders" in link or "file" in link:
|
||||
regex = r"https://drive\.google\.com/(drive)?/?u?/\d?/?mobile?/?(file)?(folders)?/?d?/([-\w]+)[?+]?/?(w+)?"
|
||||
regex = r"https://drive\.google\.com/(drive)?/?u?/?\d?/?(mobile)?/?(file)?(folders)?/?d?/([-\w]+)[?+]?/?(w+)?"
|
||||
res = re.search(regex,link)
|
||||
if res is None:
|
||||
raise IndexError("GDrive ID not found.")
|
||||
return res.group(4)
|
||||
return res.group(5)
|
||||
parsed = urlparse.urlparse(link)
|
||||
return parse_qs(parsed.query)['id'][0]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue