feat: remove mitm feature

with_status
WorldObservationLog 6 months ago
parent 54ed3e2e6e
commit 430d144958
  1. 8
      src/cmd.py
  2. 33
      src/mitm.py

@ -15,7 +15,6 @@ from src.rip import rip_song, rip_album, rip_artist, rip_playlist
from src.types import GlobalAuthParams from src.types import GlobalAuthParams
from src.url import AppleMusicURL, URLType, Song from src.url import AppleMusicURL, URLType, Song
from src.utils import get_song_id_from_m3u8 from src.utils import get_song_id_from_m3u8
from src.mitm import start_proxy
class NewInteractiveShell: class NewInteractiveShell:
@ -50,11 +49,6 @@ class NewInteractiveShell:
default="alac") default="alac")
m3u8_parser.add_argument("-f", "--force", default=False, action="store_true") m3u8_parser.add_argument("-f", "--force", default=False, action="store_true")
subparser.add_parser("exit") subparser.add_parser("exit")
mitm_parser = subparser.add_parser("mitm")
mitm_parser.add_argument("-c", "--codec",
choices=["alac", "ec3", "aac", "aac-binaural", "aac-downmix", "ac3"],
default="alac")
mitm_parser.add_argument("-f", "--force", default=False, action="store_true")
logger.remove() logger.remove()
logger.add(lambda msg: print_formatted_text(ANSI(msg), end=""), colorize=True, level="INFO") logger.add(lambda msg: print_formatted_text(ANSI(msg), end=""), colorize=True, level="INFO")
@ -87,8 +81,6 @@ class NewInteractiveShell:
await self.do_download(args.url, args.codec, args.force, args.include) await self.do_download(args.url, args.codec, args.force, args.include)
case "m3u8": case "m3u8":
await self.do_m3u8(args.url, args.codec, args.force) await self.do_m3u8(args.url, args.codec, args.force)
case "mitm":
await self.do_mitm(args.codec, args.force)
case "exit": case "exit":
self.loop.stop() self.loop.stop()
sys.exit() sys.exit()

@ -1,33 +0,0 @@
import plistlib
import mitmproxy.http
from mitmproxy import options
from mitmproxy.tools import dump
from loguru import logger
class RequestHandler:
def __init__(self, callback):
self.callback = callback
def response(self, flow: mitmproxy.http.HTTPFlow):
if flow.request.host == "play.itunes.apple.com" and flow.request.path == "/WebObjects/MZPlay.woa/wa/subPlaybackDispatch":
data = plistlib.loads(flow.response.content)
m3u8 = data["songList"][0]["hls-playlist-url"]
flow.response.status_code = 500
self.callback(m3u8)
async def start_proxy(host, port, callback):
opts = options.Options(listen_host=host, listen_port=port, mode=["socks5"])
master = dump.DumpMaster(
opts,
with_termlog=False,
with_dumper=False,
)
master.addons.add(RequestHandler(callback))
logger.info(f"Mitmproxy started at socks5://{host}:{port}")
await master.run()
Loading…
Cancel
Save