Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/anvato.py (Python)

Code before:
import json
import random
import re
import time

from .common import InfoExtractor
from ..aes import aes_encrypt
from ..utils import (
    ExtractorError,
    bytes_to_intlist,
    determine_ext,
    intlist_to_bytes,
    int_or_none,
    join_nonempty,
    strip_jsonp,
    smuggle_url,
    traverse_obj,
    unescapeHTML,
    unsmuggle_url,
)


def md5_text(s):
    if not isinstance(s, str):
        s = str(s)
    return hashlib.md5(s.encode('utf-8')).hexdigest()


class AnvatoIE(InfoExtractor):
    _VALID_URL = r'anvato:(?P<access_key_or_mcp>[^:]+):(?P<id>\d+)'

    _API_BASE_URL = 'https://tkx.mp.lura.live/rest/v2'
    _ANVP_RE = r'<script[^>]+\bdata-anvp\s*=\s*(["\'])(?P<anvp>(?:(?!\1).)+)\1'
    _AUTH_KEY = b'\x31\xc2\x42\x84\x9e\x73\xa0\xce'  # from anvplayer.min.js

    _TESTS = [{
        # from https://www.nfl.com/videos/baker-mayfield-s-game-changing-plays-from-3-td-game-week-14
        'url': 'anvato:GXvEgwyJeWem8KCYXfeoHWknwP48Mboj:899441',
        'md5': '921919dab3cd0b849ff3d624831ae3e2',
        'info_dict': {
            'id': '899441',
            'ext': 'mp4',
            'title': 'Baker Mayfield\'s game-changing plays from 3-TD game Week 14',
            'description': 'md5:85e05a3cc163f8c344340f220521136d',
            'upload_date': '20201215',
            'timestamp': 1608009755,
            'thumbnail': r're:^https?://.*\.jpg',
            'uploader': 'NFL',
            'tags': ['Baltimore Ravens at Cleveland Browns (2020-REG-14)', 'Baker Mayfield', 'Game Highlights',
                     'Player Highlights', 'Cleveland Browns', 'league'],
            'duration': 157,

Review comment (suggestion):
```suggestion
    return hashlib.md5(str(s).encode()).hexdigest()
```

Code after:
import json
import random
import re
import time

from .common import InfoExtractor
from ..aes import aes_encrypt
from ..utils import (
    bytes_to_intlist,
    determine_ext,
    intlist_to_bytes,
    int_or_none,
    join_nonempty,
    strip_jsonp,
    smuggle_url,
    traverse_obj,
    unescapeHTML,
    unsmuggle_url,
)


def md5_text(s):
    return hashlib.md5(str(s).encode()).hexdigest()


class AnvatoIE(InfoExtractor):
    _VALID_URL = r'anvato:(?P<access_key_or_mcp>[^:]+):(?P<id>\d+)'

    _API_BASE_URL = 'https://tkx.mp.lura.live/rest/v2'
    _ANVP_RE = r'<script[^>]+\bdata-anvp\s*=\s*(["\'])(?P<anvp>(?:(?!\1).)+)\1'
    _AUTH_KEY = b'\x31\xc2\x42\x84\x9e\x73\xa0\xce'  # from anvplayer.min.js

    _TESTS = [{
        # from https://www.nfl.com/videos/baker-mayfield-s-game-changing-plays-from-3-td-game-week-14
        'url': 'anvato:GXvEgwyJeWem8KCYXfeoHWknwP48Mboj:899441',
        'md5': '921919dab3cd0b849ff3d624831ae3e2',
        'info_dict': {
            'id': '899441',
            'ext': 'mp4',
            'title': 'Baker Mayfield\'s game-changing plays from 3-TD game Week 14',
            'description': 'md5:85e05a3cc163f8c344340f220521136d',
            'upload_date': '20201215',
            'timestamp': 1608009755,
            'thumbnail': r're:^https?://.*\.jpg',
            'uploader': 'NFL',
            'tags': ['Baltimore Ravens at Cleveland Browns (2020-REG-14)', 'Baker Mayfield', 'Game Highlights',
                     'Player Highlights', 'Cleveland Browns', 'league'],
            'duration': 157,
            'categories': ['Entertainment', 'Game', 'Highlights'],
        },
    }, {