Emby GDrive Autoscan is a python library that assists in notifying Emby of any changes
that are detected from the Google Drive API.
This has only been tested on a Windows server.
- Add logging
- Improve error handling with retries
This library relies heavily on the Google Drive API to retrieve changes. It pulls changes on an interval
that can be configure to avoid API bans.
Once the list of changes is retrieved, it gets the path for each file (this is done by
walking back all the parent folders via the files API). After that a call is made to the
Emby Library/Media/Updated
API.
The library uses a local DB to store important information about the drive. It stores:
- PageToken: to know it's place on the changes stream.
- Folders info: to avoid unnecessary call to the API when possible.
- Files path: to help determine when a file is deleted from the drive.
- File deletion: when a file is deleted from google drive the only info that we can
retrieve about the file is it's ID, it tries to match the ID of the deleted file in
the local database get the path so we can notify Emby that a file has been deleted.
- File deletion: when a file is deleted from google drive the only info that we can
- Python 3.0 or higher
- requirements.txt modules
git clone https://github.com/atrpm/emby_gdrive_autoscan
- clone repocd emby_gdrive_autoscan
- change directorypython -m pip install -r requirements.txt
- install all requirements- Go to Google developers getting started page and follow step 1.
Save the credentials.json file inside the emby_gdrive_autoscan directory - Configure the config.json. (do this before moving on)
python scan.py
- to run the script- Enjoy!
- General
scanIntervalMinutes
- how often show scans happenheadless
- authenticate from the console to support headless servers
- Drives (supports multiple drives)
driveId
- google drive IdcurrentPageToken: default = null
- the script will get the start page token
for the user and save the next page token after every scan. This is intended t
override that behavior if you know where to start from.pageSize: default = 100
- limit the change to get per scan, to avoid API ban.changesStartDate (iso8601 format)
- only care about changes after this date
and time.credentialsPath
- path for the credentials.json fileincludeItemsFromAllDrives: default - True
- Google API parametersupportsAllDrives: default = True
- Google API parameterincludeRemoved: default = True
- Google API parameterphysicalDriveMountLetter: default = null
- if mounted to a letter. ex. Windows X: drivemountPoint: default = null
- ex. RClone mount point of 'Media/'. null = rootretries
- number of tries for Google drive api before giving up
- Emby
apiKey
- Emby API Keyip: default = localhost
- Emby IPport: default = 8096
- Emby Portprotocol: default = http
- Emby URL protocolretries
- number of tries for Emby api before giving up