{"id":16971587,"url":"https://github.com/thomastjdev/nim_onedrive","last_synced_at":"2025-03-21T20:16:21.685Z","repository":{"id":87657480,"uuid":"231673694","full_name":"ThomasTJdev/nim_onedrive","owner":"ThomasTJdev","description":"Nim library to get information on files and folders in OneDrive","archived":false,"fork":false,"pushed_at":"2020-01-03T22:13:35.000Z","size":6,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-26T14:48:38.136Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Nim","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ThomasTJdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-03T22:10:24.000Z","updated_at":"2020-01-12T06:48:19.000Z","dependencies_parsed_at":"2023-03-11T08:01:25.567Z","dependency_job_id":null,"html_url":"https://github.com/ThomasTJdev/nim_onedrive","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasTJdev%2Fnim_onedrive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasTJdev%2Fnim_onedrive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasTJdev%2Fnim_onedrive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasTJdev%2Fnim_onedrive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThomasTJdev","download_url":"https://codeload.github.com/ThomasTJdev/nim_onedrive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244860611,"owners_count":20522466,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T00:52:48.040Z","updated_at":"2025-03-21T20:16:21.559Z","avatar_url":"https://github.com/ThomasTJdev.png","language":"Nim","readme":"# OneDrive library\n\n*Readme generated with [Nim to Markdown](https://github.com/ThomasTJdev/nimtomd)*\n\nThis is a simple library to get information on files and folders in OneDrive.\nThe library requires a public shared url to your OneDrive folder,\nwhich allows public access to files.\n\nWhen querying your OneDrive data, you get the data on the folder, and\ninformation on possible sub-folders and files. Normal querying only\ntravel 1 level down, but the lib includes a *deep-diver*, which currently\ngoes 3 levels down.\n\nThe library output objects for files (`OnedriveFile`) and for folders\n(`OnedriveFolder`).\n\nThe library uses the ole URL `https://api.onedrive.com/v1.0/shares/u!`\nwhich is not requiring any external libraries or accounts at OneDrive.\nThis library does not support Microsoft Graph at the moment. PR's are\nwelcome :)\n\n# Requirements\n\nThe lib uses `packedjson` instead of `json`.\n\n# Examples\n\n## Required code\n\nThe examples all uses this code. To access your OneDrive library\nyou need to share a folder, which will provide you with a public\nURL. Take care of that URL, since everyone can use it to access\nyour files.\n\n```nim\n import onedrive\n let publicUrl = \"https://OneDrive-public-shared-url.com\"\n let accessUrl = onedriveUrl(publicUrl)\n```\n\n\n## Get 3 levels down and print\n\nThis example first gets the root folders information, and thereafter\ngets the 3 next levels of data. Finally it prints the result.\n\n```nim\n # First access root data\n let root = onedriveRootFull(accessUrl)\n\n # Then deep dive 3 levels\n let dive = onedriveFolderDive(accessUrl, root)\n\n # Print the OneDrive structure\n onedrivePrettyPath(dive)\n # ├─ Test\n # │ ├─ 2019-12-24 - Receipt.pdf\n # │ ├─ flag_DK.png\n # │ ├─ flag_UK.png\n # │ ├─ SubFolder1\n # │ │ ├─ Zone_final2.jpg\n # │ │ ├─ newyear.jpeg\n # │ │ ├─ SubAnother\n # │ │ ├─ SubSubFolder\n # │ │ │  └─ Guide_background.jpg\n # │ │ └─ SubSubSub3\n # │ │     └─ Informed.jpg\n # │ ├─ SubFolder2\n # │ │ └─ logo.png\n # │ ├─ SubFolderEmpty\n```\n\n\n\n## Loop through subfolders names\n```nim\n let folder = onedriveFolderFull(accessUrl, \"SubFolder1\")\n echo \"Main folder: \" \u0026 folder.name\n\n # Loop through folder names\n for f in folder.childFolders:\n   echo \"Folder name: \" \u0026 f.name\n\n # Loop through file names\n for f in folder.childFiles:\n   echo \"File name: \" \u0026 f.name\n```\n\n\n## Get raw JSON result\n\nIf you prefer the raw JSON output, then use the code below.\n\n```nim\n let rootFolder         = accessUrl\n let rootFolderFull     = accessUrl \u0026 \"?expand=children\"\n let rootFolderChildren = accessUrl \u0026 \"/children\"\n let folder             = accessUrl \u0026 \":/\" \u0026 subfolderName\n let folderFull         = accessUrl \u0026 \":/\" \u0026 subfolderName \u0026 \"?expand=children\"\n let folderChildren     = accessUrl \u0026 \":/\" \u0026 subfolderName \u0026 \":/children\"\n\n let result = onedriveGetJson(folderFull)\n```\n\n# Imports\n* packedjson\n\n# Types\n```nim\n  OnedriveFile* = object\n    id*: string\n    createdByUser*: string\n    createdByUserId*: string\n    createdDateTime*: string\n    lastModifiedByUser*: string\n    lastModifiedByUserId*: string\n    lastModifiedDateTime*: string\n    name*: string\n    parentId*: string\n    size*: int\n    webUrl*: string\n    downloadUrl*: string\n    fileSha1Hash*: string\n    fileMimeType*: string\n    fileExt*: string\n    fileHeight*: int\n    fileWidth*: int\n```\n\n```nim\n  OnedriveFolder* = object\n    id*: string\n    createdByUser*: string\n    createdByUserId*: string\n    createdDateTime*: string\n    lastModifiedByUser*: string\n    lastModifiedByUserId*: string\n    lastModifiedDateTime*: string\n    name*: string\n    parentDriveId*: string\n    parentDriveType*: string\n    parentId*: string\n    parentName*: string\n    parentPath*: string\n    parentShareId*: string\n    size*: int\n    webUrl*: string\n    childCount*: int\n    childFolders*: seq[OnedriveFolder]\n    childFiles*: seq[OnedriveFile]\n    sharedEffectiveRoles*: string\n```\n# Procs\n## proc onedriveUrl*\n```nim\nproc onedriveUrl*(publicUrl: string): string =\n```\nGenerate the onedrive url, which is used in all calls.\nYou should use this to generate the access url:\nlet accessUrl = onedriveUrl(\"publicurl.com\")\n## proc onedriveGetJson*\n```nim\nproc onedriveGetJson*(url: string): JsonNode =\n```\nGet the raw JSON result.\nOnly use this, if you need the raw JSON and are parsing it yourself.\n## proc onedriveRoot*\n```nim\nproc onedriveRoot*(accessUrl: string): OnedriveFolder =\n```\nGet root folder data\n## proc onedriveRootFull*\n```nim\nproc onedriveRootFull*(accessUrl: string): OnedriveFolder =\n```\nGet root folder and data for folder and files in top level\n## proc onedriveRootChildren*\n```nim\nproc onedriveRootChildren*(accessUrl: string, folderOri: OnedriveFolder): OnedriveFolder =\n```\nWalk through subfolder and appends files and folders to the\npassed OnedriveFolder.\nOnly for root folder. Use `onedriveRootFull()` instead.\n## proc onedriveFolder*\n```nim\nproc onedriveFolder*(accessUrl, subfolderName: string): OnedriveFolder =\n```\nGets folder data\n## proc onedriveFolderFull*\n```nim\nproc onedriveFolderFull*(accessUrl, subfolderName: string): OnedriveFolder =\n```\nGets folder data and data for all files and folders in the folder level\n## proc onedriveFolderChildren*\n```nim\nproc onedriveFolderChildren*(accessUrl, subfolderName: string, folderOri: OnedriveFolder): OnedriveFolder =\n```\nWalk through subfolder and appends files and folders to the\npassed OnedriveFolder.\n## proc onedriveFolderDive*\n```nim\nproc onedriveFolderDive*(accessUrl: string, folderOri: OnedriveFolder): OnedriveFolder =\n```\nWalk through files and folders and dive nth folders down\nDRY - quick and dirty needs recursive\n## proc onedrivePrettyPath*\n```nim\nproc onedrivePrettyPath*(folder: OnedriveFolder) =\n```\nPrints the folder structure.\nDoes not print pretty - just print..\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomastjdev%2Fnim_onedrive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomastjdev%2Fnim_onedrive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomastjdev%2Fnim_onedrive/lists"}