frugglehost / TautulliBatch2Trakt

Powershell script to send Tautulli notificaions to Trakt
GNU General Public License v3.0
5 stars 1 forks source link

Critical error during setup #2

Open TheGeeKing opened 1 year ago

TheGeeKing commented 1 year ago

Describe the bug After entering my "Trackt.tv 'Client Secret':", I was getting this empty output before ps1 exiting image

To Reproduce Steps to reproduce the behavior:

  1. .\TautulliBatch2Tra22kt.ps1 -setup
  2. enter username, client ID, client secret
  3. See error

Expected behavior finishing setup process

Screenshots If applicable, add screenshots to help explain your problem. image

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

I used the Windows PowerShell ISE to find the "StatusCode:" output line and checked what was happening in the try/catch. I manually reproduced the request with the powershell, before getting an error there $TraktRest=Invoke-WebRequest -Uri $Uri -Method POST -Body $Body error:

+ $TraktRest=Invoke-WebRequest -Uri $Uri -Method POST -Body $Body
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotImplemented: (:) [Invoke-WebRequest], NotSupportedException
    + FullyQualifiedErrorId : WebCmdletIEDomNotSupportedException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

The error message says that the answer content from the request can't be analysed because internet explorer isn't available or first launch setup isn't completed. The error message also indicate to try to use the parameter -UseBasicParsing.

I added it, $TraktRest=Invoke-WebRequest -Uri $Uri -Method POST -Body $Body -UseBasicParsing and then it worked. Might be a good idea to add it to the code for stability for any type of configuration.

frugglehost commented 1 year ago

Hey TheGeeKing, thanks for the update. I was about to push the change but wanted to confirm before doing so as what version of PS are you using? I'm flipping a coin to see if adding it by default is best or to have a check added to verify the PS version at the script start up is better. In your case the quick change did the trick but I also wanted to know if you had to add the same flag to the other WebRequests too.

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.3

frugglehost commented 1 year ago

A little more googling and it looks like you might be using a windows N version or similar. Since the change will not affect others if they do have IE/Edge I agree the best bet is to add the flag.

Thanks for the commitment and looking into it!

TheGeeKing commented 1 year ago

Hey TheGeeKing, thanks for the update. I was about to push the change but wanted to confirm before doing so as what version of PS are you using? I'm flipping a coin to see if adding it by default is best or to have a check added to verify the PS version at the script start up is better. In your case the quick change did the trick but I also wanted to know if you had to add the same flag to the other WebRequests too.

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.3

image

So to add some context, Everything was working fine for months, just had to refresh the token like 2 months ago. The day I posted the issue, I instantly saw that it wasn't scrobbling anymore my movies/series. I started doing with thinking it was the token issue, so I started the setup process again but it was giving the blank issue reported above. I started to read the code and find where was the web request, I used Write-Host and your debugging/logging system to check the data and where was the error. I tried the request manually from my PS and there I got the error I mentionned in OP. I added -UseBasicParsing and then was able to do the setup step. But issues didn't finish right there. After completing the setup, it still wasn't scrobbling. So I checked tautulli logs and for the 8 first hours I get this image it was only getting status code 0 but the other half of the day it was now Status Code: 400 image

So I went to the Trakt API Doc to try to fix things, spent whole day on it, nothing worked. The strange part was that using the apiary.io console with the data in TautulliBatch2Tra22kt.log worked. So I even tried to use their proxy url, but didn't work. Meanwhile, I also opened internet explorer and did the basic setup because it was what the error was referencing to, but it didn't change anything. I also tried to download a clean version of TautulliBatch2Trakt in a new folder to retry from scratch but all the issues were still there. At the end, with the documentation and all I went to simply remake the scrobbling part with python and it's now working, and even better than before.

A little more googling and it looks like you might be using a windows N version or similar. Since the change will not affect others if they do have IE/Edge I agree the best bet is to add the flag.

The N story seemed weird to me as my windows is fresh and I installed the pro version so I checked my settings and I do have the legacy pro version image

Made some research, media-feature-pack-for-n-editions-of-windows-10-version. "The "N" editions of Windows 10 include the same functionality as other editions of Windows 10 except for media-related technologies. The N editions don't include Windows Media Player, Skype, or certain preinstalled media apps (Music, Video, Voice Recorder)." I do have Windows Media Player, Skype, Music, Video, Voice Recorder preinstalled. So not a N version.

Also in the readme here you set the output to the name of "TautulliBatch2Tra22kt.ps1" and later in the installation process here you use the "TautulliBatch2Trakt.ps1" name.

frugglehost commented 1 year ago

Sounds like my initial thoughts of requiring the -UseBasicParsing flag was not related to the version of windows or powershell. I'm glad you were able to recreate/reroute the problem in python code and now works like a champ. If you have a git hub and want to share I would like to add it to the similar projects someone else would greatly benefit.

As for the TautulliBatch2Tra22kt VS TautulliBatch2Trakt the name was a typo and was my bad on fat fingering it in and it should be called "TautulliBatch2Trakt" and was has now also been fixed!

Since there might still be a problem with the script so to keep this alive I've reopened it and will take a look at it some more to see if there is something else after I spin up a VM with your same PS and windows version.

TheGeeKing commented 1 year ago

Yeah sorry for the late reponses, seems like github doesn't want to email me when someone write a usefull comment haha.

Glad that you are still very active on this repo. I'm happy to have pointed out those issues.

I will definitely release it on github. At first, it was a personal project so code wasn't clean and entirely reproduced but now that I added personnal features like syncing collections, or auto refreshing token and fixed another issue with improper episode scrobbling, I hope to soon make it public and I will make sure to let you know.

If you need any other information about my system, let me know. I could also try to run a VM and see if I have the same issues.

Side note: The improper episode scrobbling issue should also affect TautulliBatch2Trakt, Trakt uses TMDB as their episode listing, and currently on Plex I use TheTVDB which sorts seasons differently for this show. So giving the season number and episode can point to a non existing episode on Trakt end and get a 404 error. I saw that Tautulli can give a 'ratingKey' which is a Plex server internal id, so if the request fails, I go through my show libs and search for it to then return the episode specific tvdb, tmdb, imdb ids. As I have 9k episodes it can take a bit of time, so I optimised it by making a database which makes the whole thing instant after first setup.

PS: if you get the reference https://www.youtube.com/watch?v=SiMHTK15Pik 😉

TheGeeKing commented 1 year ago

Hey,

Just to let you know that I finally released v1.0.0 of my project https://github.com/TheGeeKing/TautulliPython2Trakt.

Thanks once again for your .ps1 version that I used for a long time. Now, I will use mine as it fixes some issues I found out the .ps1 has and as it has some great features like syncing collections. I will probably try to get new features added to it. If you have any thoughts/issues, let me know!