From 4d9c52241fe8888b05af3f5c0c30762f63232b5b Mon Sep 17 00:00:00 2001 From: zentis Date: Fri, 8 Sep 2023 12:25:18 +0800 Subject: [PATCH] MTV: Add support for otp url (#242) * added support for otp url * Move pyotp import --------- Co-authored-by: Zentis <> Co-authored-by: L4GSP1KE <20821253+L4GSP1KE@users.noreply.github.com> --- requirements.txt | 1 + src/trackers/MTV.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index c118984bf..19e7c5038 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,3 +18,4 @@ beautifulsoup4 pyoxipng rich Jinja2 +pyotp \ No newline at end of file diff --git a/src/trackers/MTV.py b/src/trackers/MTV.py index 255f4890f..d4de506d1 100644 --- a/src/trackers/MTV.py +++ b/src/trackers/MTV.py @@ -12,7 +12,6 @@ from pathlib import Path from src.trackers.COMMON import COMMON - class MTV(): """ Edit for Tracker: @@ -504,9 +503,16 @@ async def login(self, cookiefile): # handle 2fa if resp.url.endswith('twofactor/login'): + otp_uri = self.config['TRACKERS'][self.tracker].get('otp_uri') + if otp_uri: + import pyotp + mfa_code = pyotp.parse_uri(otp_uri).now() + else: + mfa_code = console.input('[yellow]MTV 2FA Code: ') + two_factor_payload = { 'token' : resp.text.rsplit('name="token" value="', 1)[1][:48], - 'code' : console.input('[yellow]MTV 2FA Code: '), + 'code' : mfa_code, 'submit' : 'login' } resp = session.post(url="https://www.morethantv.me/twofactor/login", data=two_factor_payload)