Jump to content

GDrive - emby_autoscan


atrpm

Recommended Posts

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
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

  • 5 weeks later...
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
Link to comment
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? 
Link to comment
Share on other sites

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

Link to comment
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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 4 months later...
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 :(

Link to comment
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!

Link to comment
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

Link to comment
Share on other sites

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
        }
    ],
Link to comment
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!

Link to comment
Share on other sites

tattoomees

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

 

do i stilll need credencials and drive id ?

Link to comment
Share on other sites

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.

Link to comment
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 :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?
Link to comment
Share on other sites

M3th0s

 

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
Link to comment
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...