def generate_html(directory, output_file="index.html"): files = [] # Scan directory for video files video_extensions = ('.mp4', '.mkv', '.avi', '.mov', '.wmv') print(f"Scanning directory: directory...") for f in os.listdir(directory): if f.lower().endswith(video_extensions): clean_name = clean_movie_name(f) files.append( 'raw_name': f, 'clean_name': clean_name if clean_name else f, 'size': os.path.getsize(os.path.join(directory, f)) // (1024*1024) # Size in MB ) Sunkissed Affair Hot - Momcomesfirst Sarah Harlow
html_content += """ </div> <script> function searchMovies() var input = document.getElementById('searchBar').value.toLowerCase(); var cards = document.getElementsByClassName('card'); for (var i = 0; i < cards.length; i++) var title = cards[i].getElementsByClassName('title')[0].innerText.toLowerCase(); if (title.includes(input)) cards[i].style.display = ""; else cards[i].style.display = "none"; </script> </body> </html> """ Herbario De Las Brujas Pdf 007 Pdf Gratis Instant
for item in files: # Note: File links work best if you open the HTML file locally. # If this is for a web server, you might need to adjust the path logic. html_content += f""" <a href="item['raw_name']" class="card"> <div class="title">item['clean_name']</div> <div class="meta">Size: item['size'] MB | Format: item['raw_name'].split('.')[-1]</div> </a> """
with open(output_file, "w", encoding="utf-8") as f: f.write(html_content) print(f"Success! Indexed len(files) movies. Open 'output_file' to view.")
def clean_movie_name(filename): """ Removes common torrent/release tags and file extensions to guess the movie title. Example: 'Pathaan.2023.Hindi.1080p.mkv' -> 'Pathaan (2023)' """ name = os.path.splitext(filename)[0] # Remove extension # Common separators to replace with spaces name = name.replace('.', ' ').replace('_', ' ') # Remove common tags (case-insensitive) tags_to_remove = [ '1080p', '720p', '480p', 'bluray', 'web-dl', 'webrip', 'dvdscr', 'hindi', 'eng', 'dual audio', 'x264', 'x265', 'hevc', 'aac', 'mkv', 'mp4', 'avi', 'esubs', 'www', 'skymovies', 'filmyzilla' ] # Create a regex pattern to find these tags pattern = r'\b(?:' + '|'.join(re.escape(tag) for tag in tags_to_remove) + r')\b' name = re.sub(pattern, '', name, flags=re.IGNORECASE) # Clean up extra spaces name = ' '.join(name.split()) # Try to extract year for better formatting year_match = re.search(r'(19\d2|20\d2)', name) if year_match: year = year_match.group(1) name = name.replace(year, f'(year)') name = ' '.join(name.split()) # Clean spaces again
# HTML Template html_content = f""" <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Movie Index - Disk 2</title> <style> body font-family: 'Segoe UI', sans-serif; background: #1a1a1a; color: #eee; padding: 20px; h1 color: #e50914; text-align: center; #searchBar width: 100%; padding: 10px; margin-bottom: 20px; border-radius: 5px; border: none; font-size: 16px; .grid display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 15px; .card background: #2b2b2b; padding: 15px; border-radius: 8px; transition: transform 0.2s; .card:hover transform: translateY(-3px); background: #3b3b3b; .title font-weight: bold; font-size: 1.1em; margin-bottom: 5px; .meta font-size: 0.8em; color: #aaa; a color: inherit; text-decoration: none; </style> </head> <body> <h1>🍿 Hindi Movies Collection (Disk 2)</h1> <input type="text" id="searchBar" onkeyup="searchMovies()" placeholder="Search for movies..."> <div class="grid" id="movieGrid"> """