l3uddz / plex_autoscan

Script to assist sonarr/radarr with plex imports. Will only scan the folder that has been imported, instead of the whole library section.
GNU General Public License v3.0
396 stars 70 forks source link

gdrive teamdrive monitoring issues on shared teamdrive #80

Closed ktella closed 5 years ago

ktella commented 5 years ago

Seems like so far no one tested this in CentOS7. I was able to install this on CentOS7 and start it up Successfully. I couldn't get my gdrive teamdrive monitoring going. Not sure if its a config issue or something else. Running in DEBUG mode doesn't give me any errors.

ktella commented 5 years ago

Issue looks like not with OS, but with using a google teamdrive shared by others to your own google account.

Able to reproduce on ubuntu and master.

l3uddz commented 5 years ago

Try the feature/google-rewrite branch.

Config has changed regarding google now, so will need configuring and drive reauthorising.

Chudz commented 5 years ago

Hmm im getting this error when trying to authorise:

 2019-03-03 15:04:42,551 -     INFO -    CONFIG [140635795142464]: Using default setting --loglevel=INFO
 2019-03-03 15:04:42,551 -     INFO -    CONFIG [140635795142464]: Using default setting --queuefile=/opt/plex_autoscan/queue.db
 2019-03-03 15:04:42,551 -     INFO -    CONFIG [140635795142464]: Using default setting --logfile=/opt/plex_autoscan/plex_autoscan.log
 2019-03-03 15:04:42,551 -     INFO -    CONFIG [140635795142464]: Using default setting --config=/opt/plex_autoscan/config/config.json
 2019-03-03 15:04:42,552 -     INFO -    CONFIG [140635795142464]: Using default setting --cachefile=/opt/plex_autoscan/cache.db
 2019-03-03 15:04:42,667 -     INFO -        DB [140635795142464]: Created database tables
Traceback (most recent call last):
  File "/opt/plex_autoscan/scan.py", line 69, in <module>
    from google import GoogleDrive, GoogleDriveManager
  File "/opt/plex_autoscan/google/__init__.py", line 1, in <module>
    from .drive import GoogleDrive, GoogleDriveManager
  File "/opt/plex_autoscan/google/drive.py", line 9, in <module>
    from requests_oauthlib import OAuth2Session
ImportError: No module named requests_oauthlib
l3uddz commented 5 years ago

You need to install the new pip requirements.

Chudz commented 5 years ago

Working great l3uddz! thanks

Chudz commented 5 years ago

Ok I have some logs but Plex is not scanning. I have my mount at /home/chudz/gdrive/ and I have mounted the Media folder in there so you cant actually see the Media folder. (rclone mount gdrive:/Media/ ~/gdrive ....)

Here is my log:

https://0bin.net/paste/VA6QcckEVA8Vx9mI#2+6HMRJSZXJ5h+91MURxqlS6jUZ3MnIwd7TGUUn9J4J

And my config.json:

{
  "DOCKER_NAME": "plex", 
  "GOOGLE": {
    "ALLOWED": {
      "FILE_EXTENSIONS": true, 
      "FILE_EXTENSIONS_LIST": [
        "webm", 
        "mkv", 
        "flv", 
        "vob", 
        "ogv", 
        "ogg", 
        "drc", 
        "gif", 
        "gifv", 
        "mng", 
        "avi", 
        "mov", 
        "qt", 
        "wmv", 
        "yuv", 
        "rm", 
        "rmvb", 
        "asf", 
        "amv", 
        "mp4", 
        "m4p", 
        "m4v", 
        "mpg", 
        "mp2", 
        "mpeg", 
        "mpe", 
        "mpv", 
        "m2v", 
        "m4v", 
        "svi", 
        "3gp", 
        "3g2", 
        "mxf", 
        "roq", 
        "nsv", 
        "f4v", 
        "f4p", 
        "f4a", 
        "f4b", 
        "mp3", 
        "flac", 
        "ts"
      ], 
      "FILE_PATHS": [
        "PlexCloudServers/Media/"
      ], 
      "MIME_TYPES": true, 
      "MIME_TYPES_LIST": [
        "video"
      ]
    }, 
    "CLIENT_ID": "*************.apps.googleusercontent.com", 
    "CLIENT_SECRET": "*************", 
    "ENABLED": true, 
    "POLL_INTERVAL": 120, 
    "SHOW_CACHE_LOGS": true, 
    "TEAMDRIVE": true, 
    "TEAMDRIVES": [
      "PlexCloudServers"
    ]
  }, 
  "PLEX_ANALYZE_DIRECTORY": true, 
  "PLEX_ANALYZE_TYPE": "basic", 
  "PLEX_CHECK_BEFORE_SCAN": false, 
  "PLEX_DATABASE_PATH": "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db", 
  "PLEX_EMPTY_TRASH": true, 
  "PLEX_EMPTY_TRASH_CONTROL_FILES": [
    "/home/chudz/gdrive/mounted.bin"
  ], 
  "PLEX_EMPTY_TRASH_MAX_FILES": 100, 
  "PLEX_EMPTY_TRASH_ZERO_DELETED": false, 
  "PLEX_LD_LIBRARY_PATH": "/usr/lib/plexmediaserver", 
  "PLEX_LOCAL_URL": "http://localhost:32400", 
  "PLEX_SCANNER": "/usr/lib/plexmediaserver/Plex\\ Media\\ Scanner", 
  "PLEX_SECTION_PATH_MAPPINGS": {
    "1": [
      "/home/chudz/gdrive/Movies/Movies/"
    ], 
    "10": [
      "/home/chudz/gdrive/Movies/Movies-Anime/"
    ], 
    "11": [
      "/home/chudz/gdrive/TV/TV-Anime/"
    ], 
    "12": [
      "/home/chudz/gdrive/TV/TV-Classic/"
    ], 
    "13": [
      "/home/chudz/gdrive/TV/TV-4K/"
    ], 
    "2": [
      "/home/chudz/gdrive/Movies/Movies-Archive/"
    ], 
    "3": [
      "/home/chudz/gdrive/TV/TV/"
    ], 
    "4": [
      "/home/chudz/gdrive/TV/TV-Archive/"
    ], 
    "6": [
      "/home/chudz/gdrive/Movies/Movies-4K/"
    ], 
    "7": [
      "/home/chudz/gdrive/Movies/Movies-Kids/"
    ], 
    "8": [
      "/home/chudz/gdrive/Movies/Movies-Foreign/"
    ], 
    "9": [
      "/home/chudz/gdrive/TV/TV-Kids/"
    ]
  }, 
  "PLEX_SUPPORT_DIR": "/var/lib/plexmediaserver/Library/Application\\ Support", 
  "PLEX_TOKEN": "*************", 
  "PLEX_USER": "plex", 
  "PLEX_WAIT_FOR_EXTERNAL_SCANNERS": true, 
  "RCLONE_RC_CACHE_EXPIRE": {
    "ENABLED": false, 
    "FILE_EXISTS_TO_REMOTE_MAPPINGS": {
      "/home/chudz/gdrive/": [
        "/home/chudz/gdrive/"
      ]
    }, 
    "RC_URL": "http://localhost:5572"
  }, 
  "RUN_COMMAND_AFTER_SCAN": "", 
  "RUN_COMMAND_BEFORE_SCAN": "", 
  "SERVER_ALLOW_MANUAL_SCAN": false, 
  "SERVER_FILE_CHECK_DELAY": 60, 
  "SERVER_FILE_EXIST_PATH_MAPPINGS": {
    "/home/chudz/gdrive/": [
      "/home/chudz/gdrive/"
    ]
  }, 
  "SERVER_IGNORE_LIST": [
    "/.grab/", 
    ".DS_Store", 
    "Thumbs.db"
  ], 
  "SERVER_IP": "0.0.0.0", 
  "SERVER_MAX_FILE_CHECKS": 10, 
  "SERVER_PASS": "*************", 
  "SERVER_PATH_MAPPINGS": {
    "/home/chudz/gdrive/": [
      "PlexCloudServers/Media/"
    ]
  }, 
  "SERVER_PORT": 3467, 
  "SERVER_SCAN_DELAY": 180, 
  "SERVER_SCAN_FOLDER_ON_FILE_EXISTS_EXHAUSTION": false, 
  "SERVER_SCAN_PRIORITIES": {
    "0": [
      "/Movies/"
    ], 
    "1": [
      "/TV/"
    ], 
    "2": [
      "/Music/"
    ]
  }, 
  "SERVER_USE_SQLITE": false, 
  "USE_DOCKER": false, 
  "USE_SUDO": true
}

When I check this directory "/home/chudz/gdrive/TV/TV-Archive/2 Broke Girls/Season 04/" the files do exist here.

Chudz commented 5 years ago

So had disable file analysis in plex_autoscan and im getting this now:

 2019-03-05 16:33:08,283 -     INFO -      PLEX [140142694098688]: Starting Plex Scanner
 2019-03-05 16:33:08,302 -     INFO -     UTILS [140142694098688]: sudo: no tty present and no askpass program specified
 2019-03-05 16:33:08,303 -     INFO -      PLEX [140142694098688]: Finished scan!

Any ideas what "sudo: no tty present and no askpass program specified" means?

ktella commented 5 years ago

Can we get some help here please ?

zenjabba commented 5 years ago

https://www.thisisarecording.com/q/payphone-nynex-fleet.mp3

hthighway commented 5 years ago

The user that runs plex_autoscan needs to beable to sudo, without a password otherwise, it cannot execute the PLEX_SCANNER as plex. This can be disabled by config option USE_SUDO.

On Tue, Mar 5, 2019, 7:35 AM Andrew Jones notifications@github.com wrote:

So had disable file analysis in plex_autoscan and im getting this now:

2019-03-05 16:33:08,283 - INFO - PLEX [140142694098688]: Starting Plex Scanner 2019-03-05 16:33:08,302 - INFO - UTILS [140142694098688]: sudo: no tty present and no askpass program specified 2019-03-05 16:33:08,303 - INFO - PLEX [140142694098688]: Finished scan!

Any ideas what "sudo: no tty present and no askpass program specified" means?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/l3uddz/plex_autoscan/issues/80#issuecomment-469726114, or mute the thread https://github.com/notifications/unsubscribe-auth/AEDVX07lafGBkfuoqI6JbKxYi7pP-AnHks5vTo6xgaJpZM4bSrjw .

l3uddz commented 5 years ago

Can we get some help here please ?

Help with what?

As mentioned above, the user running the plex_autoscan service / script needs to be able to run sudo without a password being asked. This is so it can sudo -u plex execute the scanner.

If the user running the script is also the user running Plex Media Server, then you can turn off USE_SUDO and it will run the scanner without using sudo -u plex.

Regarding team drives, if you read earlier, you would have seen the google-rewrite branch was recommended for testing (others are using this branch and have been for the last week without any issues so far). It will be merged into develop this weekend most likely.

dcplaya commented 5 years ago

I switched to this branch and I am getting the following issue

/opt/plex_autoscan # ./scan.py authorize
 2019-03-14 06:15:49,539 -     INFO -    CONFIG [140205005592384]: Using default setting --loglevel=INFO
 2019-03-14 06:15:49,540 -     INFO -    CONFIG [140205005592384]: Using default setting --queuefile=./queue.db
 2019-03-14 06:15:49,540 -     INFO -    CONFIG [140205005592384]: Using default setting --logfile=./plex_autoscan.log
 2019-03-14 06:15:49,540 -     INFO -    CONFIG [140205005592384]: Using default setting --config=./config/config.json
 2019-03-14 06:15:49,540 -     INFO -    CONFIG [140205005592384]: Using default setting --cachefile=./cache.db
Traceback (most recent call last):
  File "./scan.py", line 69, in <module>
    from google import GoogleDrive, GoogleDriveManager
ImportError: cannot import name GoogleDrive

I have installed the requirements and even did a pip install google just in case.

sbcrumb commented 5 years ago

also getting this same issue 2019-05-28 17:07:49,402 - INFO - CONFIG [140223554889536]: Using default setting --loglevel=INFO 2019-05-28 17:07:49,403 - INFO - CONFIG [140223554889536]: Using default setting --queuefile=./queue.db 2019-05-28 17:07:49,403 - INFO - CONFIG [140223554889536]: Using default setting --logfile=./plex_autoscan.log 2019-05-28 17:07:49,403 - INFO - CONFIG [140223554889536]: Using default setting --config=./config/config.json 2019-05-28 17:07:49,403 - INFO - CONFIG [140223554889536]: Using default setting --cachefile=./cache.db 2019-05-28 17:07:49,437 - INFO - DB [140223554889536]: Created database tables Traceback (most recent call last): File "./scan.py", line 73, in <module> from google import GoogleDrive, GoogleDriveManager ImportError: cannot import name GoogleDrive

desimaniac commented 5 years ago

Notice that all the log examples above you are in code blocks.

Anyways, this is not an issue with PAS but with Python on your system. As such, I'm pasting a possible solution from our Discord server and closing the ticket.

Fix:

  1. stop everything in docker (if this applies).

  2. do a ps aux grep python and sudo kill -9 <process> related to python

  3. run this command: pip freeze | xargs sudo pip uninstall -y

  4. Run CB dependencies script or reinstall python 3 and then python 2.

  5. reboot

  6. rerun CB ansible playbook (if this applies) or reinstall pip requirements.

Update: Fixed typo in commands.

sbcrumb commented 5 years ago

Sorry for not putting in the code wraps. I thought I hit them. I will give this a try.