import requests
import json
# URL to fetch the movie JSON
json_url = "https://vidsrc.vip/list/movie.json"
# Output file for generated HTML
output_file = "auto_movies.html"
def fetch_movie_data():
"""Fetch movie data from the JSON URL."""
try:
response = requests.get(json_url)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
print(f"Error fetching data: {e}")
return []
def generate_html(movies):
"""Generate HTML content for the movies."""
html_content = """
Auto-Generated Movies
"""
html_content += """
"""
return html_content
def save_html(content):
"""Save the generated HTML content to a file."""
try:
with open(output_file, "w", encoding="utf-8") as file:
file.write(content)
print(f"HTML file saved as {output_file}")
except IOError as e:
print(f"Error saving file: {e}")
def main():
# Step 1: Fetch data
movies = fetch_movie_data()
# Step 2: Generate HTML content
if movies:
html_content = generate_html(movies)
# Step 3: Save to file
save_html(html_content)
else:
print("No movies found.")
if __name__ == "__main__":
main()