(self, doc_link)
| 11671 | return {} |
| 11672 | |
| 11673 | def analyze_gdrive_doc(self, doc_link): |
| 11674 | target = (doc_link or "").strip() |
| 11675 | target_norm = target.lower() |
| 11676 | candidates = self._collect_drive_id_candidates(target) |
| 11677 | |
| 11678 | doc_id = candidates[0] if candidates else "" |
| 11679 | if not doc_id: |
| 11680 | return { |
| 11681 | "username": target or "Google Doc", |
| 11682 | "type": "Doc GDrive", |
| 11683 | "info": { |
| 11684 | "Status": "Document ID non trovato", |
| 11685 | "Suggerimento": "Inserisci un link Google Docs/Sheets/Drive pubblico contenente un ID valido." |
| 11686 | }, |
| 11687 | "main_img": "https://ssl.gstatic.com/docs/doclist/images/drive_2022q3_32dp.png", |
| 11688 | "status_code": 404, |
| 11689 | "url": target |
| 11690 | } |
| 11691 | |
| 11692 | gdrive_api_key = (os.environ.get("GOOGLE_DRIVE_API_KEY") or "").strip() |
| 11693 | if not gdrive_api_key: |
| 11694 | probe = self._drive_probe_variant(doc_id) |
| 11695 | info = { |
| 11696 | "Status": "Google Drive API key non configurata", |
| 11697 | "Setup": "Imposta GOOGLE_DRIVE_API_KEY nelle variabili d'ambiente per abilitare le API Drive.", |
| 11698 | "ID Documento": doc_id, |
| 11699 | } |
| 11700 | if probe.get("title"): |
| 11701 | info["Titolo pubblico"] = probe.get("title") |
| 11702 | info["URL pubblico"] = probe.get("url") |
| 11703 | if probe.get("author"): |
| 11704 | info["Metadati pubblici"] = probe.get("author") |
| 11705 | return { |
| 11706 | "username": probe.get("title") or target or "Google Drive", |
| 11707 | "type": "Doc GDrive", |
| 11708 | "info": info, |
| 11709 | "main_img": "https://ssl.gstatic.com/docs/doclist/images/drive_2022q3_32dp.png", |
| 11710 | "status_code": 503, |
| 11711 | "url": target |
| 11712 | } |
| 11713 | v2_fields = ( |
| 11714 | "alternateLink,copyRequiresWriterPermission,createdDate,description,driveId,fileSize,iconLink,id,title,name,mimeType," |
| 11715 | "labels(starred,trashed),lastViewedByMeDate,modifiedDate,shared,teamDriveId," |
| 11716 | "userPermission(id,name,emailAddress,domain,role,additionalRoles,photoLink,type,withLink)," |
| 11717 | "permissions(id,name,emailAddress,domain,role,additionalRoles,photoLink,type,withLink)," |
| 11718 | "owners(id,permissionId,name,displayName,emailAddress,domain,photoLink)," |
| 11719 | "lastModifyingUser(displayName,emailAddress,id,domain)," |
| 11720 | "parents(id),capabilities(canMoveItemWithinDrive,canMoveItemOutOfDrive,canMoveItemOutOfTeamDrive," |
| 11721 | "canAddChildren,canEdit,canDownload,canComment,canMoveChildrenWithinDrive,canRename,canRemoveChildren," |
| 11722 | "canMoveItemIntoTeamDrive),kind" |
| 11723 | ) |
| 11724 | v3_fields = ( |
| 11725 | "id,name,mimeType,size,description,createdTime,modifiedTime,lastModifyingUser(displayName,emailAddress,id)," |
| 11726 | "shared,copyRequiresWriterPermission,iconLink,owners(permissionId,displayName,emailAddress,id,domain,photoLink)," |
| 11727 | "permissions(id,role,displayName,emailAddress,domain,additionalRoles,type,withLink)," |
| 11728 | "webViewLink,webContentLink,capabilities(canEdit,canDownload,canComment,canRename,canRemoveChildren)," |
| 11729 | "driveId,fileExtension,kind" |
| 11730 | ) |
no test coverage detected