mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 20:31:35 +00:00
Handle folder alternateLink (#343)
This commit is contained in:
26
src/gam.py
26
src/gam.py
@@ -4141,6 +4141,23 @@ def doDriveSearch(drive, query=None):
|
|||||||
ids.append(f_file[u'id'])
|
ids.append(f_file[u'id'])
|
||||||
return ids
|
return ids
|
||||||
|
|
||||||
|
def getFileIdFromAlternateLink(altLink):
|
||||||
|
loc = altLink.find(u'/d/')
|
||||||
|
if loc > 0:
|
||||||
|
fileId = altLink[loc+3:]
|
||||||
|
loc = fileId.find(u'/')
|
||||||
|
if loc != -1:
|
||||||
|
return fileId[:loc]
|
||||||
|
else:
|
||||||
|
loc = altLink.find(u'/folderview?id=')
|
||||||
|
if loc > 0:
|
||||||
|
fileId = altLink[loc+15:]
|
||||||
|
loc = fileId.find(u'&')
|
||||||
|
if loc != -1:
|
||||||
|
return fileId[:loc]
|
||||||
|
print u'ERROR: %s is not a valid Drive File alternateLink' % altLink
|
||||||
|
sys.exit(2)
|
||||||
|
|
||||||
DELETE_DRIVEFILE_FUNCTION_TO_ACTION_MAP = {u'delete': u'purging', u'trash': u'trashing', u'untrash': u'untrashing',}
|
DELETE_DRIVEFILE_FUNCTION_TO_ACTION_MAP = {u'delete': u'purging', u'trash': u'trashing', u'untrash': u'untrashing',}
|
||||||
|
|
||||||
def deleteDriveFile(users):
|
def deleteDriveFile(users):
|
||||||
@@ -4166,9 +4183,7 @@ def deleteDriveFile(users):
|
|||||||
file_ids = doDriveSearch(drive, query=fileIds[6:])
|
file_ids = doDriveSearch(drive, query=fileIds[6:])
|
||||||
else:
|
else:
|
||||||
if fileIds[:8].lower() == u'https://' or fileIds[:7].lower() == u'http://':
|
if fileIds[:8].lower() == u'https://' or fileIds[:7].lower() == u'http://':
|
||||||
fileIds = fileIds[fileIds.find(u'/d/')+3:]
|
fileIds = getFileIdFromAlternateLink(fileIds)
|
||||||
if fileIds.find(u'/') != -1:
|
|
||||||
fileIds = fileIds[:fileIds.find(u'/')]
|
|
||||||
file_ids = [fileIds,]
|
file_ids = [fileIds,]
|
||||||
if not file_ids:
|
if not file_ids:
|
||||||
print u'No files to %s for %s' % (function, user)
|
print u'No files to %s for %s' % (function, user)
|
||||||
@@ -4543,10 +4558,7 @@ def downloadDriveFile(users):
|
|||||||
else:
|
else:
|
||||||
fileId = fileIdSelection[u'fileIds'][0]
|
fileId = fileIdSelection[u'fileIds'][0]
|
||||||
if fileId[:8].lower() == u'https://' or fileId[:7].lower() == u'http://':
|
if fileId[:8].lower() == u'https://' or fileId[:7].lower() == u'http://':
|
||||||
fileId = fileId[fileId.find(u'/d/')+3:]
|
fileIdSelection[u'fileIds'][0] = getFileIdFromAlternateLink(fileId)
|
||||||
if fileId.find(u'/') != -1:
|
|
||||||
fileId = fileId[:fileId.find(u'/')]
|
|
||||||
fileIdSelection[u'fileIds'][0] = fileId
|
|
||||||
if not fileIdSelection[u'fileIds']:
|
if not fileIdSelection[u'fileIds']:
|
||||||
print u'No files to download for %s' % user
|
print u'No files to download for %s' % user
|
||||||
i = 0
|
i = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user