Jump to content
atrpm

GDrive - emby_autoscan

Recommended Posts

atrpm

I have been working on a python script to pull file changes from GDrive using google’s api, get the file info and send a request to emby’s api to update the file path via the library/media/updated endpoint.

So far I have been able to successfully do this, script have been running with no issues for 24 hrs before I make it public there are a few improvements that I have to make.

I have tested this on a windows machine, I would like to find a few ppl with different OS to make sure that it works fine there, so please is interested send a PM.

I do have an Emby related question, after a request has been sent and media is scheduled to be refreshed, what happens if the server is restarted before that task is completed?

 

Here is the github link: https://github.com/atrpm/emby_gdrive_autoscan

Edited by atrpm
  • Like 2

Share this post


Link to post
Share on other sites
Luke

Hi, if it's restarted then you'll have to send it again or just wait for the next library scan.

Share this post


Link to post
Share on other sites
atrpm

Hi, if it's restarted then you'll have to send it again or just wait for the next library scan.

Luke if I send the path including the file name, will emby only scan that file or will it still scan the entire directory?

Share this post


Link to post
Share on other sites
Luke

Depends. In some cases it will scan the entire directory.

Share this post


Link to post
Share on other sites
atrpm

Updated the post with the github link. 

Share this post


Link to post
Share on other sites
Luke

Thanks for the info !

Share this post


Link to post
Share on other sites
drmikewest

Thank you for this and a quick question.

 

Configuring the config.json file, but I am not sure what to insert in this field: 

 

driveId - google drive ID

 

What do I use for the "Google Drive ID"

 

I have tried various iterations of my Gsuite login (xyz@@abc.com) but to no avail.

Should I rather be using something else? 

 

Hope this question makes sense...

Edited by drmikewest

Share this post


Link to post
Share on other sites
Luke

What config.json file? I have no idea what you mean, sorry.

Share this post


Link to post
Share on other sites
drmikewest

What config.json file? I have no idea what you mean, sorry.

 

From the github page: https://github.com/atrpm/emby_gdrive_autoscan

 

Installation, Step 5: 

Configure the config.json. (do this before moving on)

 

In the config.json is a field: "driveId": "insert drive id here"

[i'm at a loss as to what I should insert as my drive id?]

 

When I run the scan.py script, I receive the following error: 

  File "scan.py", line 19
    print(f'Starting scan for: {drive.driveId}')
                                              ^
SyntaxError: invalid syntax
 
 
Hoping that's a little clearer and makes somewhat more sense? 

Share this post


Link to post
Share on other sites
Luke

Ok sorry I don't know very much about this tool but perhaps there is someone here that does. Thanks.

Share this post


Link to post
Share on other sites
drmikewest

Ok sorry I don't know very much about this tool but perhaps there is someone here that does. Thanks.

 

Thanks anyways.

 

Hoping @@atrpm sees this...

Share this post


Link to post
Share on other sites
atrpm

Thanks anyways.

 

Hoping @@atrpm sees this...

 

The google drive id (as google calls it in its API documentation) is the folder ID where your media is store at. The way that I found mine was from the URL, after the folder path ex. https://drive.google.com/drive/folders/drive-id-should-be-here. So, if you go into the folder from your web browser you should be able to find it.

 

Also, I just push so bug fixes so make sure to get the latest code.

Share this post


Link to post
Share on other sites
saitoh183

@atrpm 

 

How can i use this on a headless ubuntu server? cant get pass the authorized application stage as i get a error because it is not done on the same machine. Couldn't you do like rclone or plexdrive did by using a response token that we can paste into terminal?

 

Was all excited to use this :(

Share this post


Link to post
Share on other sites
saitoh183

@atrpm 

 

How can i use this on a headless ubuntu server? cant get pass the authorized application stage as i get a error because it is not done on the same machine. Couldn't you do like rclone or plexdrive did by using a response token that we can paste into terminal?

 

Was all excited to use this :(

 

fixed on git...thanks!

Share this post


Link to post
Share on other sites
M3th0s

Can I use this to scan team drives? That being the case 2 questions:

  • Can I point this towards the root "Media" folder in a team drive and it'll still do its work?
  • Can I set this up with multiple team drives?

Thanks in advance

Share this post


Link to post
Share on other sites
atrpm

Can I use this to scan team drives? That being the case 2 questions:

  • Can I point this towards the root "Media" folder in a team drive and it'll still do its work?
  • Can I set this up with multiple team drives?

Thanks in advance

 

Yes, this works with team drives, that's how I use it.

  • Pointing to an specific folders is not supported at the moment, you can point it to the entire drive and if a change is detected it will be send to Emby. I will do nothing since it wont find a match for that path.
  • Yes, you can set it up for multiple drives. I have not test this since I don't use multiple drives but in the config file, the drives section is a json array, you can add multiple ones, like this:
"drives": [
        {
            "driveId": "insert drive id here",
            "currentPageToken": null,
            "pageSize": 100,
            "changesStartDate": "2019-09-04T00:00:00",
            "credentialsPath": "credentials.json",
            "includeItemsFromAllDrives": true,
            "supportsAllDrives": true,
            "includeRemoved": true,
            "physicalDriveMountLetter": null,
            "mountPoint": null,
            "retries": 3
        },
        {
            "driveId": "drive 2",
            "currentPageToken": null,
            "pageSize": 100,
            "changesStartDate": "2019-09-04T00:00:00",
            "credentialsPath": "credentials2.json",
            "includeItemsFromAllDrives": true,
            "supportsAllDrives": true,
            "includeRemoved": true,
            "physicalDriveMountLetter": null,
            "mountPoint": null,
            "retries": 3
        }
    ],

Share this post


Link to post
Share on other sites
M3th0s

 

Yes, this works with team drives, that's how I use it.

  • Pointing to an specific folders is not supported at the moment, you can point it to the entire drive and if a change is detected it will be send to Emby. I will do nothing since it wont find a match for that path.
  • Yes, you can set it up for multiple drives. I have not test this since I don't use multiple drives but in the config file, the drives section is a json array, you can add multiple ones, like this:
"drives": [
        {
            "driveId": "insert drive id here",
            "currentPageToken": null,
            "pageSize": 100,
            "changesStartDate": "2019-09-04T00:00:00",
            "credentialsPath": "credentials.json",
            "includeItemsFromAllDrives": true,
            "supportsAllDrives": true,
            "includeRemoved": true,
            "physicalDriveMountLetter": null,
            "mountPoint": null,
            "retries": 3
        },
        {
            "driveId": "drive 2",
            "currentPageToken": null,
            "pageSize": 100,
            "changesStartDate": "2019-09-04T00:00:00",
            "credentialsPath": "credentials2.json",
            "includeItemsFromAllDrives": true,
            "supportsAllDrives": true,
            "includeRemoved": true,
            "physicalDriveMountLetter": null,
            "mountPoint": null,
            "retries": 3
        }
    ],

I'm using this on ubuntu 18.04 with an rclone mount, so rather than drive guessing I'd be pointing this to the mount point?

 

Thanks again for your help!

Share this post


Link to post
Share on other sites
tattoomees

if i "mountPoint": null, change "mountPoint": /mnt/unionfs ,

 

do i stilll need credencials and drive id ?

Share this post


Link to post
Share on other sites
atrpm

I'm using this on ubuntu 18.04 with an rclone mount, so rather than drive guessing I'd be pointing this to the mount point?

 

Thanks again for your help!

 

They are different things. mount point and folder are not related in terms of this script. The setting mountPoint for the drive in the config.json has to match the rclone mount point on the system otherwise it will not work.

Share this post


Link to post
Share on other sites
M3th0s

They are different things. mount point and folder are not related in terms of this script. The setting mountPoint for the drive in the config.json has to match the rclone mount point on the system otherwise it will not work.

Sorry just noticed there's a mountpoint variable :)

Share this post


Link to post
Share on other sites
atrpm

if i "mountPoint": null, change "mountPoint": /mnt/unionfs ,

 

do i stilll need credencials and drive id ?

 

 

Yes, the script needs a way to connect to the google drive api and query for changes. 

 

The script uses mountPoint to generate the complete system path and let emby know to go and scan that directory. Ex. From google drive api what we get is that something changed in folderId/Media/Movie/SomeMovieFolder. The script needs to convert that to /mnt/myMount/Media/Movie/SomeMovieFolder or in windows D:/Media/Movie/SomeMovieFolder.

 

Hope that helps.

Share this post


Link to post
Share on other sites
tattoomees

do you have fully working sample file without credencials its bit confusig .

Share this post


Link to post
Share on other sites
atrpm

do you have fully working sample file without credencials its bit confusig .

 

Sure,

  • Are you using Windows or Linux?
  • How are you mounting the drive? (rclone or something else)
  • What is your mount point and or letter (if windows)?
  • Is this for a Team Drive (Shared Drive) or a Personal Drive?

Share this post


Link to post
Share on other sites
M3th0s
Posted (edited)

 

Sure,

  • Are you using Windows or Linux?
  • How are you mounting the drive? (rclone or something else)
  • What is your mount point and or letter (if windows)?
  • Is this for a Team Drive (Shared Drive) or a Personal Drive?

 

Hello again

 

I keep getting

 

  File "scan.py", line 19
    print(f'Starting scan for: {drive.driveId}')
                                              ^
SyntaxError: invalid syntax
 

Working on a headless machine, so changed that to true. Config json is there, but no dice.

 

Any help appreciated :)

Edited by M3th0s

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...