{
"info": {
"author": "Kanshi TANAIKE",
"author_email": "tanaike@hotmail.com",
"bugtrack_url": null,
"classifiers": [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3.5"
],
"description": "# getfilelistpy\n\n[](https://travis-ci.org/tanaikech/getfilelistpy)\n[](LICENCE)\n\n\n\n# Overview\n\nThis is a python library to retrieve the file list with the folder tree from the specific folder of Google Drive.\n\n# Description\n\nWhen I create applications for using Google Drive, I often retrieve a file list from a folder in the application. So far, I had created the script for retrieving a file list from a folder for each application. Recently, I thought that if there is the script for retrieving the file list with the folder tree from the folder of Google Drive as a library, it will be useful for me and other users. So I created this.\n\n## Features\n\n- This library retrieves all files from a folder in Google Drive.\n- All files include the folder structure in Google Drive.\n- Only folder tree can be also retrieved.\n\n# Install\n\n```\n$ pip install getfilelistpy\n```\n\nYou can also check this library at [https://pypi.org/project/getfilelistpy/](https://pypi.org/project/getfilelistpy/).\n\n# Method\n\n| Method | Explanation |\n| :-------------------- | :----------------------------------------------------- |\n| GetFolderTree(object) | Retrieve only folder structure from a folder |\n| GetFileList(object) | Retrieve file list with folder structure from a folder |\n\n# Usage\n\nThere are 3 patterns for using this library.\n\n## 1. Use API key\n\nThis is a sample script using API key. When you want to retrieve the API key, please do the following flow.\n\n1. Login to Google.\n2. Access to [https://console.cloud.google.com/?hl=en](https://console.cloud.google.com/?hl=en).\n3. Click select project at the right side of \"Google Cloud Platform\" of upper left of window.\n4. Click \"NEW PROJECT\"\n 1. Input \"Project Name\".\n 2. Click \"CREATE\".\n 3. Open the created project.\n 4. Click \"Enable APIs and get credentials like keys\".\n 5. Click \"Library\" at left side.\n 6. Input \"Drive API\" in \"Search for APIs & Services\".\n 7. Click \"Google Drive API\".\n 8. Click \"ENABLE\".\n 9. Back to [https://console.cloud.google.com/?hl=en](https://console.cloud.google.com/?hl=en).\n 10. Click \"Enable APIs and get credentials like keys\".\n 11. Click \"Credentials\" at left side.\n 12. Click \"Create credentials\" and select API key.\n 13. Copy the API key. You can use this API key.\n\n### Sample script\n\n```python\nfrom getfilelistpy import getfilelist\n\nresource = {\n \"api_key\": \"#####\",\n \"id\": \"### Folder ID ###\",\n \"fields\": \"files(name,id)\",\n}\nres = getfilelist.GetFileList(resource) # or r = getfilelist.GetFolderTree(resource)\nprint(res)\n```\n\n### Note\n\n- **When you want to retrieve the file list from the folder using API key, the folder is required to be shared.**\n- You can modify the property of `fields`. When this is not used, the default fields are used.\n\n## 2. Use OAuth2\n\nDocument of OAuth2 is [here](https://developers.google.com/identity/protocols/OAuth2).\n\n### Sample script 1\n\nIn this sample script for `oauth2client`.\n\n```python\nfrom httplib2 import Http\nfrom oauth2client import file, client, tools\nfrom getfilelistpy import getfilelist\n\nSCOPES = 'https://www.googleapis.com/auth/drive.metadata.readonly'\n\nstore = file.Storage('token.json')\ncreds = store.get()\nif not creds or creds.invalid:\n flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)\n creds = tools.run_flow(flow, store)\n\nresource = {\n \"oauth2\": creds.authorize(Http()),\n \"id\": \"### Folder ID ###\",\n \"fields\": \"files(name,id)\",\n}\nres = getfilelist.GetFileList(resource) # or r = getfilelist.GetFolderTree(resource)\nprint(res)\n```\n\n\n\n### Sample script 2\n\nIn this sample script for `google_auth_oauthlib`, the process of OAuth2 uses [the quickstart of Google](https://developers.google.com/drive/api/v3/quickstart/python). Please check this.\n\n```python\nimport pickle\nimport os.path\nfrom google_auth_oauthlib.flow import InstalledAppFlow\nfrom google.auth.transport.requests import Request\nfrom getfilelistpy import getfilelist\n\nSCOPES = 'https://www.googleapis.com/auth/drive.metadata.readonly'\n\ncreds = None\n\ncreFile = 'token.pickle'\nif os.path.exists(creFile):\n with open(creFile, 'rb') as token:\n creds = pickle.load(token)\nif not creds or not creds.valid:\n if creds and creds.expired and creds.refresh_token:\n creds.refresh(Request())\n else:\n flow = InstalledAppFlow.from_client_secrets_file(\n 'client_secret.json', SCOPES)\n creds = flow.run_local_server()\n with open(creFile, 'wb') as token:\n pickle.dump(creds, token)\n\nresource = {\n \"oauth2\": creds,\n \"id\": \"### Folder ID ###\",\n \"fields\": \"files(name,id)\",\n}\nres = getfilelist.GetFileList(resource) # or r = getfilelist.GetFolderTree(resource)\nprint(res)\n```\n\n### Note\n\n- Here, as a sample, the script of the authorization uses the script of [quickstart](https://developers.google.com/drive/api/v3/quickstart/python).\n- You can modify the property of `fields`. When this is not used, the default fields are used.\n\n## 3. Use Service account\n\nDocument of Service account is [here](https://developers.google.com/identity/protocols/OAuth2ServiceAccount).\n\n### Sample script\n\n```python\nfrom google.oauth2 import service_account\nfrom getfilelistpy import getfilelist\n\nSCOPES = ['https://www.googleapis.com/auth/drive']\nSERVICE_ACCOUNT_FILE = 'service-account-credentials.json'\ncredentials = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES)\n\nresource = {\n \"service_account\": credentials,\n \"id\": \"### Folder ID ###\",\n \"fields\": \"files(name,id)\",\n}\nres = getfilelist.GetFileList(resource) # or r = getfilelist.GetFolderTree(resource)\nprint(res)\n```\n\n### Note\n\n- You can modify the property of `fields`. When this is not used, the default fields are used.\n\n# Values\n\n\n\nAs a sample, when the values are retrieved from above structure, the results of `GetFolderTree()` becomes as follows.\n\n## Values retrieved by GetFolderTree()\n\n```python\nres = getfilelist.GetFolderTree(resource)\nprint(res)\n```\n\n```json\n{\n \"id\": [\n [\"folderIdOfsampleFolder1\"],\n [\"folderIdOfsampleFolder1\", \"folderIdOfsampleFolder_2a\"],\n [\"folderIdOfsampleFolder1\", \"folderIdOfsampleFolder_2b\"],\n [\n \"folderIdOfsampleFolder1\",\n \"folderIdOfsampleFolder_2a\",\n \"folderIdOfsampleFolder_2a_3a\"\n ],\n [\n \"folderIdOfsampleFolder1\",\n \"folderIdOfsampleFolder_2b\",\n \"folderIdOfsampleFolder_2b_3a\"\n ],\n [\n \"folderIdOfsampleFolder1\",\n \"folderIdOfsampleFolder_2b\",\n \"folderIdOfsampleFolder_2b_3b\"\n ],\n [\n \"folderIdOfsampleFolder1\",\n \"folderIdOfsampleFolder_2b\",\n \"folderIdOfsampleFolder_2b_3b\",\n \"folderIdOfsampleFolder_2b_3b_4a\"\n ]\n ],\n \"names\": [\n \"sampleFolder1\",\n \"sampleFolder_2a\",\n \"sampleFolder_2b\",\n \"sampleFolder_2a_3a\",\n \"sampleFolder_2b_3a\",\n \"sampleFolder_2b_3b\",\n \"sampleFolder_2b_3b_4a\"\n ],\n \"folders\": [\n \"folderIdOfsampleFolder1\",\n \"folderIdOfsampleFolder_2a\",\n \"folderIdOfsampleFolder_2b\",\n \"folderIdOfsampleFolder_2a_3a\",\n \"folderIdOfsampleFolder_2b_3a\",\n \"folderIdOfsampleFolder_2b_3b\",\n \"folderIdOfsampleFolder_2b_3b_4a\"\n ]\n}\n```\n\n## Values retrieved by Do()\n\n```python\nres = getfilelist.GetFileList(resource)\nprint(res)\n```\n\n```json\n{\n \"searchedFolder\": {\n \"id\": \"###\",\n \"name\": \"sampleFolder1\",\n \"mimeType\": \"application/vnd.google-apps.folder\",\n \"parents\": [\"###\"],\n \"createdTime\": \"2000-01-01T01:23:45.000Z\",\n \"modifiedTime\": \"2000-01-01T01:23:45.000Z\",\n \"webViewLink\": \"https://drive.google.com/drive/folders/###\",\n \"owners\": [\n { \"displayName\": \"###\", \"permissionId\": \"###\", \"emailAddress\": \"###\" }\n ],\n \"shared\": true\n },\n \"folderTree\": {\n \"id\": [\n [\"folderIdOfsampleFolder1\"],\n [\"folderIdOfsampleFolder1\", \"folderIdOfsampleFolder_2a\"],\n [\"folderIdOfsampleFolder1\", \"folderIdOfsampleFolder_2b\"],\n [\n \"folderIdOfsampleFolder1\",\n \"folderIdOfsampleFolder_2a\",\n \"folderIdOfsampleFolder_2a_3a\"\n ],\n [\n \"folderIdOfsampleFolder1\",\n \"folderIdOfsampleFolder_2b\",\n \"folderIdOfsampleFolder_2b_3a\"\n ],\n [\n \"folderIdOfsampleFolder1\",\n \"folderIdOfsampleFolder_2b\",\n \"folderIdOfsampleFolder_2b_3b\"\n ],\n [\n \"folderIdOfsampleFolder1\",\n \"folderIdOfsampleFolder_2b\",\n \"folderIdOfsampleFolder_2b_3b\",\n \"folderIdOfsampleFolder_2b_3b_4a\"\n ]\n ],\n \"names\": [\n \"sampleFolder1\",\n \"sampleFolder_2a\",\n \"sampleFolder_2b\",\n \"sampleFolder_2a_3a\",\n \"sampleFolder_2b_3a\",\n \"sampleFolder_2b_3b\",\n \"sampleFolder_2b_3b_4a\"\n ],\n \"folders\": [\n \"folderIdOfsampleFolder1\",\n \"folderIdOfsampleFolder_2a\",\n \"folderIdOfsampleFolder_2b\",\n \"folderIdOfsampleFolder_2a_3a\",\n \"folderIdOfsampleFolder_2b_3a\",\n \"folderIdOfsampleFolder_2b_3b\",\n \"folderIdOfsampleFolder_2b_3b_4a\"\n ]\n },\n \"fileList\": [\n {\n \"folderTree\": [\"folderIdOfsampleFolder1\"],\n \"files\": [\n {\n \"name\": \"Spreadsheet1\",\n \"mimeType\": \"application/vnd.google-apps.spreadsheet\"\n }\n ]\n },\n {\n \"folderTree\": [\"folderIdOfsampleFolder1\", \"folderIdOfsampleFolder_2a\"],\n \"files\": [\n {\n \"name\": \"Spreadsheet2\",\n \"mimeType\": \"application/vnd.google-apps.spreadsheet\"\n }\n ]\n },\n {\n \"folderTree\": [\"folderIdOfsampleFolder1\", \"folderIdOfsampleFolder_2b\"],\n \"files\": [\n {\n \"name\": \"Spreadsheet4\",\n \"mimeType\": \"application/vnd.google-apps.spreadsheet\"\n }\n ]\n },\n {\n \"folderTree\": [\n \"folderIdOfsampleFolder1\",\n \"folderIdOfsampleFolder_2a\",\n \"folderIdOfsampleFolder_2a_3a\"\n ],\n \"files\": null\n },\n {\n \"folderTree\": [\n \"folderIdOfsampleFolder1\",\n \"folderIdOfsampleFolder_2b\",\n \"folderIdOfsampleFolder_2b_3a\"\n ],\n \"files\": [\n {\n \"name\": \"Spreadsheet3\",\n \"mimeType\": \"application/vnd.google-apps.spreadsheet\"\n }\n ]\n },\n {\n \"folderTree\": [\n \"folderIdOfsampleFolder1\",\n \"folderIdOfsampleFolder_2b\",\n \"folderIdOfsampleFolder_2b_3b\"\n ],\n \"files\": null\n },\n {\n \"folderTree\": [\n \"folderIdOfsampleFolder1\",\n \"folderIdOfsampleFolder_2b\",\n \"folderIdOfsampleFolder_2b_3b\",\n \"folderIdOfsampleFolder_2b_3b_4a\"\n ],\n \"files\": [\n {\n \"name\": \"Document1\",\n \"mimeType\": \"application/vnd.google-apps.document\"\n },\n {\n \"name\": \"image1.png\",\n \"mimeType\": \"image/png\"\n },\n {\n \"name\": \"Slides1\",\n \"mimeType\": \"application/vnd.google-apps.presentation\"\n },\n {\n \"name\": \"Spreadsheet5\",\n \"mimeType\": \"application/vnd.google-apps.spreadsheet\"\n },\n {\n \"name\": \"StandaloneProject1\",\n \"mimeType\": \"application/vnd.google-apps.script\"\n },\n {\n \"name\": \"Test1.txt\",\n \"mimeType\": \"text/plain\"\n }\n ]\n }\n ],\n \"totalNumberOfFiles\": 10,\n \"totalNumberOfFolders\": 7\n}\n```\n\n---\n\n\n\n# Licence\n\n[MIT](LICENCE)\n\n\n\n# Author\n\n[Tanaike](https://tanaikech.github.io/about/)\n\nIf you have any questions and commissions for me, feel free to tell me.\n\n\n\n# Update History\n\n- v1.0.0 (November 17, 2018)\n\n 1. Initial release.\n\n- v1.0.3 (July 16, 2019)\n\n 1. Markdown format was used to the readme file at [https://pypi.org/project/getfilelistpy/](https://pypi.org/project/getfilelistpy/).\n\n- v1.0.4 (August 23, 2019)\n\n 1. For OAuth2, `oauth2client` and `google_auth_oauthlib` got to be able to be used. About the sample script for `google_auth_oauthlib`, please see [this](#googleauthoauthlibsample).\n\n[TOP](#top)\n\n\n",
"description_content_type": "text/markdown",
"docs_url": null,
"download_url": "",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://github.com/tanaikech/getfilelistpy",
"keywords": "google drive,drive api,folder structure,folder tree,folder hierarchy,file list",
"license": "MIT License",
"maintainer": "",
"maintainer_email": "",
"name": "getfilelistpy",
"package_url": "https://pypi.org/project/getfilelistpy/",
"platform": "",
"project_url": "https://pypi.org/project/getfilelistpy/",
"project_urls": {
"Homepage": "https://github.com/tanaikech/getfilelistpy"
},
"release_url": "https://pypi.org/project/getfilelistpy/1.0.4/",
"requires_dist": [
"google-api-python-client"
],
"requires_python": "",
"summary": "This is a python library to retrieve the file list with the folder tree from the specific folder of Google Drive.",
"version": "1.0.4"
},
"last_serial": 5719005,
"releases": {
"1.0.0": [
{
"comment_text": "",
"digests": {
"md5": "773d0df800a14b4e0ae252431462eeb6",
"sha256": "d53ab0f5324fb797d3fddc5594e1fc035c8c91ce00e8552789e18dfd485e2ebf"
},
"downloads": -1,
"filename": "getfilelistpy-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "773d0df800a14b4e0ae252431462eeb6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4394,
"upload_time": "2018-11-17T05:37:25",
"url": "https://files.pythonhosted.org/packages/32/ba/90f77a456232e4937be5d2a356e9cafb6362fa1dcdacda0ad74e1a0b8d49/getfilelistpy-1.0.0-py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "73af4347f2b0145dddea800b6e28d8d6",
"sha256": "042f003e5a027bc3fb92047d0dcf1d920bdc637c59988e1504ad421fd6a367f0"
},
"downloads": -1,
"filename": "getfilelistpy-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "73af4347f2b0145dddea800b6e28d8d6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6338,
"upload_time": "2018-11-17T05:37:27",
"url": "https://files.pythonhosted.org/packages/bc/c5/157cb0b33aa967d38a4e42ffabef4936883a05f0d255255425b92bc88334/getfilelistpy-1.0.0.tar.gz"
}
],
"1.0.1": [
{
"comment_text": "",
"digests": {
"md5": "01903540695ddb038bfec8b1b2c1e662",
"sha256": "80616d154a01761b4ee1cf5a6c3d06f2e760b7479efedcdf0e81dde5ec12ec4f"
},
"downloads": -1,
"filename": "getfilelistpy-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "01903540695ddb038bfec8b1b2c1e662",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 6763,
"upload_time": "2018-11-17T05:51:54",
"url": "https://files.pythonhosted.org/packages/5c/b9/c58e90db15afdf1842bef45b003516db8c339d927e006ca8f052a6075eac/getfilelistpy-1.0.1-py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "e3d031c58ef0c6fd265db6ae40dc4513",
"sha256": "e58ac6ee6c1690ad31ffbac083b5697986d62452f07cadcc11f2a3d974f29722"
},
"downloads": -1,
"filename": "getfilelistpy-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "e3d031c58ef0c6fd265db6ae40dc4513",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7476,
"upload_time": "2018-11-17T05:51:56",
"url": "https://files.pythonhosted.org/packages/b2/45/14dbd97b53eb456826c4fc6f018c3211ad1d8189a6832069e6b3d63c4f87/getfilelistpy-1.0.1.tar.gz"
}
],
"1.0.3": [
{
"comment_text": "",
"digests": {
"md5": "613957a8e93f0f0e22b3f59397aee3a9",
"sha256": "8cb1fd676896f41e6eb96607ad9e38ae636aaabd88190e351dd7426e4660141c"
},
"downloads": -1,
"filename": "getfilelistpy-1.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "613957a8e93f0f0e22b3f59397aee3a9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 7600,
"upload_time": "2019-07-16T02:27:12",
"url": "https://files.pythonhosted.org/packages/fb/ab/ffd630af6faa8c14ba2a580e70dc249a6ca4c1faab1d17f25acc7fa365c8/getfilelistpy-1.0.3-py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "c5a3e591886352ef0735d71a153ae491",
"sha256": "fb6d45590b190f462be61926a640a223c4642d33c8e0a5a8ebbaaa4a25eac512"
},
"downloads": -1,
"filename": "getfilelistpy-1.0.3.tar.gz",
"has_sig": false,
"md5_digest": "c5a3e591886352ef0735d71a153ae491",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7521,
"upload_time": "2019-07-16T02:27:13",
"url": "https://files.pythonhosted.org/packages/68/49/3daf2991bb31ff979c8e8922922c9249b64382850ad5003cee89ac42330f/getfilelistpy-1.0.3.tar.gz"
}
],
"1.0.4": [
{
"comment_text": "",
"digests": {
"md5": "b37f7c70fa98bf444511cca9a1195e83",
"sha256": "01ad1e4dd049d493fd79131372147602fb61701ad6daf752c4ce7e183d5dd772"
},
"downloads": -1,
"filename": "getfilelistpy-1.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b37f7c70fa98bf444511cca9a1195e83",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 8141,
"upload_time": "2019-08-23T06:07:30",
"url": "https://files.pythonhosted.org/packages/db/33/63065bd59b504908eeda44ae8908825d86432a050aa08cb5f845f4ff3a88/getfilelistpy-1.0.4-py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "c779923928b3a2bc3e1b7dc23e111366",
"sha256": "7d871bd4778bd0c10fb75a67ed63394ddde9dbad39b0ace7a5e6015bb9072030"
},
"downloads": -1,
"filename": "getfilelistpy-1.0.4.tar.gz",
"has_sig": false,
"md5_digest": "c779923928b3a2bc3e1b7dc23e111366",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8288,
"upload_time": "2019-08-23T06:07:32",
"url": "https://files.pythonhosted.org/packages/01/ff/fb79a8120493794494acbee95e78cb8cb819724e043ad7ad9d3b5e706c63/getfilelistpy-1.0.4.tar.gz"
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "b37f7c70fa98bf444511cca9a1195e83",
"sha256": "01ad1e4dd049d493fd79131372147602fb61701ad6daf752c4ce7e183d5dd772"
},
"downloads": -1,
"filename": "getfilelistpy-1.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b37f7c70fa98bf444511cca9a1195e83",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 8141,
"upload_time": "2019-08-23T06:07:30",
"url": "https://files.pythonhosted.org/packages/db/33/63065bd59b504908eeda44ae8908825d86432a050aa08cb5f845f4ff3a88/getfilelistpy-1.0.4-py3-none-any.whl"
},
{
"comment_text": "",
"digests": {
"md5": "c779923928b3a2bc3e1b7dc23e111366",
"sha256": "7d871bd4778bd0c10fb75a67ed63394ddde9dbad39b0ace7a5e6015bb9072030"
},
"downloads": -1,
"filename": "getfilelistpy-1.0.4.tar.gz",
"has_sig": false,
"md5_digest": "c779923928b3a2bc3e1b7dc23e111366",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8288,
"upload_time": "2019-08-23T06:07:32",
"url": "https://files.pythonhosted.org/packages/01/ff/fb79a8120493794494acbee95e78cb8cb819724e043ad7ad9d3b5e706c63/getfilelistpy-1.0.4.tar.gz"
}
]
}