60 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
		
		
			
		
	
	
			60 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| 
								 | 
							
								import base64
							 | 
						||
| 
								 | 
							
								import hashlib
							 | 
						||
| 
								 | 
							
								import json
							 | 
						||
| 
								 | 
							
								import re
							 | 
						||
| 
								 | 
							
								from codecs import Codec
							 | 
						||
| 
								 | 
							
								from collections.abc import Generator
							 | 
						||
| 
								 | 
							
								from datetime import datetime, timedelta
							 | 
						||
| 
								 | 
							
								from http.cookiejar import CookieJar
							 | 
						||
| 
								 | 
							
								from typing import Optional, Union
							 | 
						||
| 
								 | 
							
								import click
							 | 
						||
| 
								 | 
							
								from langcodes import Language
							 | 
						||
| 
								 | 
							
								from unshackle.core.console import console
							 | 
						||
| 
								 | 
							
								from unshackle.core.constants import AnyTrack
							 | 
						||
| 
								 | 
							
								from unshackle.core.credential import Credential
							 | 
						||
| 
								 | 
							
								from unshackle.core.manifests import DASH
							 | 
						||
| 
								 | 
							
								from unshackle.core.search_result import SearchResult
							 | 
						||
| 
								 | 
							
								from unshackle.core.service import Service
							 | 
						||
| 
								 | 
							
								from unshackle.core.session import session
							 | 
						||
| 
								 | 
							
								from unshackle.core.titles import Episode, Movie, Movies, Series, Title_T, Titles_T
							 | 
						||
| 
								 | 
							
								from unshackle.core.tracks import Chapter, Subtitle, Tracks, Video, Chapters
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								class HMAX(Service):
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    """
							 | 
						||
| 
								 | 
							
								    Service code for HBO Max
							 | 
						||
| 
								 | 
							
								    Author: TPD94
							 | 
						||
| 
								 | 
							
								    Version: 1.0.0
							 | 
						||
| 
								 | 
							
								    Authorization:
							 | 
						||
| 
								 | 
							
								    Security:
							 | 
						||
| 
								 | 
							
								    Use Series ID/URL (for example - ).
							 | 
						||
| 
								 | 
							
								    """
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    @staticmethod
							 | 
						||
| 
								 | 
							
								    @click.command(name="HMAX", short_help="https://hbomax.com/",
							 | 
						||
| 
								 | 
							
								                   help="""
							 | 
						||
| 
								 | 
							
								                       Service code for HBO Max\n
							 | 
						||
| 
								 | 
							
								                       Author: TPD94\n
							 | 
						||
| 
								 | 
							
								                       Version: 1.0.0\n
							 | 
						||
| 
								 | 
							
								                       Authorization:\n
							 | 
						||
| 
								 | 
							
								                       Security:\n
							 | 
						||
| 
								 | 
							
								                       Use full URL (for example - ).
							 | 
						||
| 
								 | 
							
								                       """
							 | 
						||
| 
								 | 
							
								                   )
							 | 
						||
| 
								 | 
							
								    @click.argument("title", type=str)
							 | 
						||
| 
								 | 
							
								    @click.pass_context
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    def cli(ctx, **kwargs):
							 | 
						||
| 
								 | 
							
								        return HMAX(ctx, **kwargs)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    def __init__(self, ctx, title):
							 | 
						||
| 
								 | 
							
								        super().__init__(ctx)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    def get_session(self):
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        # Create a session using curl_cffi as it can impersonate browsers and avoid bot detection by HBO Max
							 | 
						||
| 
								 | 
							
								        return session("chrome124")
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    def authenticate(self, cookies: Optional[CookieJar] = None, credential: Optional[Credential] = None) -> None:
							 | 
						||
| 
								 | 
							
								        super().authenticate(cookies, credential)
							 |