Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] v1.6.2 Issue with Trakt Auth and Restart #237

Closed
ekk88d opened this issue Dec 31, 2022 · 3 comments
Closed

[BUG] v1.6.2 Issue with Trakt Auth and Restart #237

ekk88d opened this issue Dec 31, 2022 · 3 comments

Comments

@ekk88d
Copy link

ekk88d commented Dec 31, 2022

Describe the bug

A clear and concise description of what the bug/error is.

Desktop (please complete the following information):
OS and Version: Windows 10, Powershell v7.3.1

Python Version: 3.9.7

Player and Version: Only player is MPC-BE w/listening enabled and 13679 port defined

Environment variables defined in PATH:
C:\Users\<user>\AppData\Local\Programs\Python\Python39\Scripts\
C:\Users\<user>\AppData\Local\Programs\Python\Python39\
C:\Users\<user>\.local\bin (which has one file - trakts.exe)

To Reproduce

  1. Updated from v1.6.1 to v1.6.2 to fix previous issue
  2. Ran "trakts init"
  3. Set MPC-HC and port
  4. Didn't see TS picking up any scrobbling activity, so I checked log and saw:
2022-12-30 22:13:18,651 - DEBUG - scrobbler - scrobbler - Scrobbling start at 2.09% for Echo 3
2022-12-30 22:13:18,757 - WARNING - scrobbler - utils - Request failed
  1. Forced new Trakt auth token and then forced a restart, which returned these results:
PS C:\Program Files\PowerShell\7> trakts auth -f
Forcing trakt authentication
Open https://trakt.tv/activate in your browser and enter this code: C9AA120A
App authorized successfully.
Token valid until 03/31/23
WNDPROC return value cannot be converted to LRESULT
PS C:\Program Files\PowerShell\7> trakts status
The scrobbler is running
Monitored players: mpc-hc
No activity yet.
PS C:\Program Files\PowerShell\7> trakts start --restart
SUCCESS: The process with PID 14100 (child process of PID 7524) has been terminated.
SUCCESS: The process with PID 7524 (child process of PID 3604) has been terminated.
ERROR: The process with PID 3604 (child process of PID 16340) could not be terminated.
Reason: There is no running instance of the task.

  CalledProcessError

  Command '['taskkill', '/pid', '3604', '/f', '/t']' returned non-zero exit status 255.

  at ~\AppData\Local\Programs\Python\Python39\lib\subprocess.py:373 in check_call
       369│     if retcode:
       370│         cmd = kwargs.get("args")
       371│         if cmd is None:
       372│             cmd = popenargs[0]
    →  373│         raise CalledProcessError(retcode, cmd)
       374│     return 0
       375│
       376│
       377│ def check_output(*popenargs, timeout=None, **kwargs):

Log file

Log Contents 1 of 2

2022-12-30 22:13:50,107 - INFO - MainThread - trakt_auth - Access token not found. Initiating device authentication.
2022-12-30 22:13:50,269 - INFO - MainThread - trakt_auth - Verification URL: https://trakt.tv/activate
2022-12-30 22:13:50,269 - INFO - MainThread - trakt_auth - User Code: C9AA120A
2022-12-30 22:13:50,540 - WARNING - MainThread - utils - Request failed
2022-12-30 22:13:50,540 - DEBUG - MainThread - utils - Request: post {'url': 'https://api.trakt.tv/oauth/device/token', 'headers': {'Content-Type': 'application/json'}, 'json': {'code': '91d72b4fd4ec3cc325446de397416b997f26cddd13c2cd1496780cbed0f1f216', 'client_id': 'ab0133a2365b2c64d70fd2adf3c7e775a4131471b56340933335af1b94785a3a', 'client_secret': 'b574acd5857310fcdc1e195c5953795fc61a1d89d69fec1649624d54cb666222'}}
2022-12-30 22:13:50,540 - DEBUG - MainThread - utils - Response: <Response [400]> 
2022-12-30 22:13:50,540 - DEBUG - MainThread - trakt_auth - Waiting for user to authorize the app.
2022-12-30 22:13:55,628 - WARNING - MainThread - utils - Request failed
2022-12-30 22:13:55,628 - DEBUG - MainThread - utils - Request: post {'url': 'https://api.trakt.tv/oauth/device/token', 'headers': {'Content-Type': 'application/json'}, 'json': {'code': '91d72b4fd4ec3cc325446de397416b997f26cddd13c2cd1496780cbed0f1f216', 'client_id': 'ab0133a2365b2c64d70fd2adf3c7e775a4131471b56340933335af1b94785a3a', 'client_secret': 'b574acd5857310fcdc1e195c5953795fc61a1d89d69fec1649624d54cb666222'}}
2022-12-30 22:13:55,629 - DEBUG - MainThread - utils - Response: <Response [400]> 
2022-12-30 22:13:55,629 - DEBUG - MainThread - trakt_auth - Waiting for user to authorize the app.
2022-12-30 22:14:00,720 - WARNING - MainThread - utils - Request failed
2022-12-30 22:14:00,720 - DEBUG - MainThread - utils - Request: post {'url': 'https://api.trakt.tv/oauth/device/token', 'headers': {'Content-Type': 'application/json'}, 'json': {'code': '91d72b4fd4ec3cc325446de397416b997f26cddd13c2cd1496780cbed0f1f216', 'client_id': 'ab0133a2365b2c64d70fd2adf3c7e775a4131471b56340933335af1b94785a3a', 'client_secret': 'b574acd5857310fcdc1e195c5953795fc61a1d89d69fec1649624d54cb666222'}}
2022-12-30 22:14:00,720 - DEBUG - MainThread - utils - Response: <Response [400]> 
2022-12-30 22:14:00,720 - DEBUG - MainThread - trakt_auth - Waiting for user to authorize the app.
2022-12-30 22:14:05,821 - INFO - MainThread - trakt_auth - App authorized successfully.
2022-12-30 22:14:20,343 - ERROR - Thread-1 - __init__ - Unhandled exception
TypeError: WPARAM is simple, so must be an int object (got NoneType)
2022-12-30 22:14:30,901 - DEBUG - mpc-hc - monitor - action=scrobble
2022-12-30 22:14:30,901 - DEBUG - mpc-hc - monitor - {'state': 1, 'progress': 4.76, 'media_info': {'type': 'episode', 'title': 'Echo 3', 'season': 1, 'episode': 8, 'year': 2022}, 'updated_at': 1672460070.9012554}
2022-12-30 22:14:30,901 - DEBUG - scrobbler - scrobbler - Scrobbling pause at 4.76% for Echo 3
2022-12-30 22:14:30,992 - WARNING - scrobbler - utils - Request failed
2022-12-30 22:14:30,992 - DEBUG - scrobbler - utils - Request: post {'url': 'https://api.trakt.tv/scrobble/pause', 'headers': {'Content-Type': 'application/json', 'trakt-api-key': 'ab0133a2365b2c64d70fd2adf3c7e775a4131471b56340933335af1b94785a3a', 'trakt-api-version': '2', 'Authorization': 'Bearer f734e2deaaacc29701c094d333eecc5d170962b2c58125cfe5b920f0ed53d59f'}, 'json': {'show': {'ids': {'trakt': 164514}}, 'episode': {'season': 1, 'number': 8}, 'progress': 4.76}, 'timeout': 30}
2022-12-30 22:14:30,992 - DEBUG - scrobbler - utils - Response: <Response [401]> 
2022-12-30 22:14:30,992 - WARNING - scrobbler - scrobbler - Scrobble unsuccessful. Discarding it.

  1. Forced restart seemed to fail, but tried "trakts start" instead. It resulted in a bunch of old episodes being added to the backlog cleaner, a proper activity report for the last Paused position in the MPC-HC file, and this addition to the log:
2022-12-30 22:33:15,981 - DEBUG - scrobbler - scrobbler - Scrobbling pause at 6.46% for Echo 3
2022-12-30 22:33:16,108 - INFO - scrobbler - scrobbler - Scrobble pause successful for Echo 3 S01E08 at 6.46%
2022-12-30 22:33:16,110 - ERROR - scrobbler - __init__ - Unhandled exception
Traceback (most recent call last):
  File "C:\Users\J\AppData\Local\Programs\Python\Python39\lib\threading.py", line 973, in _bootstrap_inner
    self.run()
  File "C:\Users\J\.local\pipx\venvs\trakt-scrobbler\lib\site-packages\trakt_scrobbler\scrobbler.py", line 36, in run
    self.scrobble(verb, data)
  File "C:\Users\J\.local\pipx\venvs\trakt-scrobbler\lib\site-packages\trakt_scrobbler\scrobbler.py", line 80, in scrobble
    self.handle_successful_scrobble(verb, data, resp)
  File "C:\Users\J\.local\pipx\venvs\trakt-scrobbler\lib\site-packages\trakt_scrobbler\scrobbler.py", line 67, in handle_successful_scrobble
    action = Button(
TypeError: object() takes no arguments
2022-12-30 22:33:21,188 - ERROR - Thread-4 - __init__ - Unhandled exception
TypeError: WPARAM is simple, so must be an int object (got NoneType)
@iamkroot
Copy link
Owner

You're seeing two separate issues

  1. Regarding auth, see [BUG] Response 401: Scrobbles unsuccesful #234 (comment) (in short, force auth should have fixed it)
  2. For the other exception, I've pushed a fix. Please give it a try from here-
    Install from branch:
    1. Stop the scrobbler with trakts stop
    2. Run pipx install --force --pip-args='--force-reinstall' git+https://github.com/iamkroot/trakt-scrobbler.git@notif-fix
    3. Start scrobbler with trakts start

@sharkykh
Copy link
Contributor

sharkykh commented Jan 1, 2023

@iamkroot
(Not OP, but) I essentially made the same fix as the one on notif-fix before I seeing this bug report.
Can confirm this fixes TypeError: object() takes no arguments on Windows 10, and that the toast shows up.

@iamkroot
Copy link
Owner

iamkroot commented Jan 6, 2023

Fixed in 97569b9

@iamkroot iamkroot closed this as completed Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants