Jump to content


Photo

GDrive - emby_autoscan

GDrive Autoscan Scan Google Drive

  • Please log in to reply
54 replies to this topic

#1 atrpm OFFLINE  

atrpm

    Advanced Member

  • Members
  • 66 posts
  • Local time: 07:35 PM

Posted 03 September 2019 - 08:24 PM

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/a...gdrive_autoscan


Edited by atrpm, 05 September 2019 - 02:37 PM.

  • lucasferrari3 and M3th0s like this

#2 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 156920 posts
  • Local time: 06:35 PM

Posted 03 September 2019 - 08:42 PM

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

#3 atrpm OFFLINE  

atrpm

    Advanced Member

  • Members
  • 66 posts
  • Local time: 07:35 PM

Posted 03 September 2019 - 09:21 PM

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?

#4 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 156920 posts
  • Local time: 06:35 PM

Posted 03 September 2019 - 10:11 PM

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

#5 atrpm OFFLINE  

atrpm

    Advanced Member

  • Members
  • 66 posts
  • Local time: 07:35 PM

Posted 05 September 2019 - 02:38 PM

Updated the post with the github link. 



#6 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 156920 posts
  • Local time: 06:35 PM

Posted 05 September 2019 - 02:40 PM

Thanks for the info !



#7 drmikewest OFFLINE  

drmikewest

    Newbie

  • Members
  • 3 posts
  • Local time: 12:35 AM

Posted 05 October 2019 - 01:27 PM

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, 05 October 2019 - 01:28 PM.


#8 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 156920 posts
  • Local time: 06:35 PM

Posted 05 October 2019 - 01:35 PM

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

#9 drmikewest OFFLINE  

drmikewest

    Newbie

  • Members
  • 3 posts
  • Local time: 12:35 AM

Posted 05 October 2019 - 01:42 PM

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

 

From the github page: https://github.com/a...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? 


#10 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 156920 posts
  • Local time: 06:35 PM

Posted 05 October 2019 - 01:43 PM

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

#11 drmikewest OFFLINE  

drmikewest

    Newbie

  • Members
  • 3 posts
  • Local time: 12:35 AM

Posted 05 October 2019 - 01:54 PM

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...



#12 atrpm OFFLINE  

atrpm

    Advanced Member

  • Members
  • 66 posts
  • Local time: 07:35 PM

Posted 05 October 2019 - 09:38 PM

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...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.



#13 atrpm OFFLINE  

atrpm

    Advanced Member

  • Members
  • 66 posts
  • Local time: 07:35 PM

Posted 05 October 2019 - 09:39 PM

Here is a great example. https://ploi.io/docu...drive-folder-id



#14 saitoh183 OFFLINE  

saitoh183

    Advanced Member

  • Members
  • 1000 posts
  • Local time: 06:35 PM
  • LocationCanada, St-Eustache, QC

Posted 03 March 2020 - 08:32 PM

@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 :(



#15 saitoh183 OFFLINE  

saitoh183

    Advanced Member

  • Members
  • 1000 posts
  • Local time: 06:35 PM
  • LocationCanada, St-Eustache, QC

Posted 05 March 2020 - 06:18 PM

@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!



#16 M3th0s OFFLINE  

M3th0s

    Advanced Member

  • Members
  • 103 posts
  • Local time: 11:35 PM

Posted 09 March 2020 - 11:52 AM

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



#17 atrpm OFFLINE  

atrpm

    Advanced Member

  • Members
  • 66 posts
  • Local time: 07:35 PM

Posted 09 March 2020 - 03:20 PM

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
        }
    ],


#18 M3th0s OFFLINE  

M3th0s

    Advanced Member

  • Members
  • 103 posts
  • Local time: 11:35 PM

Posted 09 March 2020 - 04:13 PM

 

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!



#19 tattoomees OFFLINE  

tattoomees

    Advanced Member

  • Members
  • 47 posts
  • Local time: 11:35 PM

Posted 09 March 2020 - 05:03 PM

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

 

do i stilll need credencials and drive id ?



#20 atrpm OFFLINE  

atrpm

    Advanced Member

  • Members
  • 66 posts
  • Local time: 07:35 PM

Posted 09 March 2020 - 05:09 PM

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.







Also tagged with one or more of these keywords: GDrive, Autoscan, Scan, Google, Drive

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users