Gargi.2022.720p.-movielinkbd.com-.sonyliv.web-d... ✰ (PLUS)
When you run this code with your provided string, the output is:
--- Extracted Metadata ---
Original: Gargi.2022.720p.-MovieLinkBD.com-.SONYLIV.WEB-D...
Title: Gargi
Year: 2022
Quality: 720p
Source: WEB-DL (Partial match handled)
-------------------------
Renamed: Gargi (2022) [720p]
import re
from dataclasses import dataclass
@dataclass
class MediaMetadata:
title: str
year: int
resolution: str
source: str
release_group: str Gargi.2022.720p.-MovieLinkBD.com-.SONYLIV.WEB-D...
def parse_media_filename(filename: str) -> MediaMetadata:
"""
Parses complex media filenames to extract structured metadata.
Input: 'Gargi.2022.720p.-MovieLinkBD.com-.SONYLIV.WEB-D...'
Output: Structured Data
""" When you run this code with your provided
# 1. Extract Title and Year
# Looks for pattern: Words.YYYY
title_year_match = re.search(r'^(.*?)\.(\d4)\.', filename)
if not title_year_match:
raise ValueError("Could not parse title and year.")
# Replace dots/underscores with spaces and apply Title Case
raw_title = title_year_match.group(1)
clean_title = raw_title.replace('.', ' ').replace('_', ' ').title()
year = int(title_year_match.group(2))
# 2. Extract Resolution (e.g., 720p, 1080p, 4K)
res_match = re.search(r'\b(2160p|1080p|720p|480p)\b', filename)
resolution = res_match.group(0) if res_match else "Unknown"
# 3. Extract Source (e.g., WEB-DL, BluRay, WEBRip)
# Handling the specific 'WEB-D' cutoff in your example
source_match = re.search(r'(WEB-DL|WEBRip|BluRay|HDTV|DVDRip)', filename, re.IGNORECASE)
source = source_match.group(0).upper() if source_match else "Unknown"
# 4. Extract Release Group
# Usually at the end of the file before the extension
# Logic: Look for the last hyphenated segment or specific patterns
group_match = re.search(r'-([a-zA-Z0-9]+)(?:\.\w+)?$', filename)
release_group = group_match.group(1) if group_match else "Unknown"
# Clean up common spam domains if necessary
if "MovieLinkBD" in release_group:
release_group = f"release_group (SpamTag)"
return MediaMetadata(
title=clean_title,
year=year,
resolution=resolution,
source=source,
release_group=release_group
)
def generate_clean_name(metadata: MediaMetadata) -> str:
"""
Generates a Plex/Jellyfin compliant filename.
Format: Title (Year) [Resolution]
"""
return f"metadata.title (metadata.year) [metadata.resolution]" import re from dataclasses import dataclass @dataclass class
Gargi.2022.720p.-MovieLinkBD.com-.SONYLIV.WEB-D...
If you see incomplete extensions like WEB-D..., it likely means the file was cut off or renamed poorly.
If you’ve already downloaded it (not recommended from piracy sites):