diff --git a/apps/proxy/vod_proxy/views.py b/apps/proxy/vod_proxy/views.py index 51578109..e13220eb 100644 --- a/apps/proxy/vod_proxy/views.py +++ b/apps/proxy/vod_proxy/views.py @@ -390,12 +390,7 @@ class VODStreamView(View): else: logger.warning(f"[VOD-URL] get_stream_url() returned None") - # Fallback to stored URL field (for backwards compatibility) - if hasattr(relation, 'url') and relation.url: - logger.info(f"[VOD-URL] Using stored URL: {relation.url}") - return relation.url - - logger.error(f"[VOD-URL] Relation has no URL or get_stream_url method failed") + logger.error(f"[VOD-URL] Relation has no get_stream_url method or it failed") return None except Exception as e: logger.error(f"[VOD-URL] Error getting stream URL from relation: {e}", exc_info=True) diff --git a/apps/vod/migrations/0005_remove_m3umovierelation_url.py b/apps/vod/migrations/0005_remove_m3umovierelation_url.py new file mode 100644 index 00000000..bde8e845 --- /dev/null +++ b/apps/vod/migrations/0005_remove_m3umovierelation_url.py @@ -0,0 +1,17 @@ +# Generated by Django 5.2.4 on 2025-08-19 15:07 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('vod', '0004_alter_movie_unique_together_and_more'), + ] + + operations = [ + migrations.RemoveField( + model_name='m3umovierelation', + name='url', + ), + ] diff --git a/apps/vod/models.py b/apps/vod/models.py index fff511fc..e4a99a0d 100644 --- a/apps/vod/models.py +++ b/apps/vod/models.py @@ -182,7 +182,6 @@ class M3UMovieRelation(models.Model): category = models.ForeignKey(VODCategory, on_delete=models.SET_NULL, null=True, blank=True) # Streaming information (provider-specific) - url = models.URLField(max_length=2048) stream_id = models.CharField(max_length=255, help_text="External stream ID from M3U provider") container_extension = models.CharField(max_length=10, blank=True, null=True) @@ -204,19 +203,15 @@ class M3UMovieRelation(models.Model): def get_stream_url(self): """Get the full stream URL for this movie from this provider""" - # If we have a stored URL, use it - if self.url: - return self.url - - # Otherwise, build URL dynamically for XtreamCodes accounts + # Build URL dynamically for XtreamCodes accounts if self.m3u_account.account_type == 'XC': server_url = self.m3u_account.server_url.rstrip('/') username = self.m3u_account.username password = self.m3u_account.password return f"{server_url}/movie/{username}/{password}/{self.stream_id}.{self.container_extension or 'mp4'}" else: - # For other account types, we need a stored URL - return self.url + # For other account types, we would need another way to build URLs + return None class M3UEpisodeRelation(models.Model): diff --git a/apps/vod/tasks.py b/apps/vod/tasks.py index d740db07..9a909bb6 100644 --- a/apps/vod/tasks.py +++ b/apps/vod/tasks.py @@ -374,7 +374,6 @@ def process_movie_batch(account, batch, category_map): movie=movie, category=category, stream_id=stream_id, - url='', # Will be set later if needed container_extension=movie_data.get('container_extension', 'mp4'), custom_properties={ 'basic_data': movie_data, @@ -430,7 +429,7 @@ def process_movie_batch(account, batch, category_map): if relations_to_update: M3UMovieRelation.objects.bulk_update(relations_to_update, [ - 'movie', 'category', 'url', 'container_extension', 'custom_properties' + 'movie', 'category', 'container_extension', 'custom_properties' ]) logger.info("Movie batch processing completed successfully!") @@ -492,6 +491,14 @@ def process_series_batch(account, batch, category_map): genre = series_data.get('genre', '') logo_url = series_data.get('cover') or '' + # Extract additional metadata for custom_properties + additional_metadata = {} + for key in ['backdrop_path', 'poster_path', 'original_name', 'first_air_date', 'last_air_date', + 'episode_run_time', 'status', 'type', 'cast', 'director', 'country', 'language', + 'releaseDate', 'youtube_trailer', 'category_id', 'age', 'seasons']: + if series_data.get(key): + additional_metadata[key] = series_data[key] + series_props = { 'name': name, 'year': year, @@ -500,6 +507,7 @@ def process_series_batch(account, batch, category_map): 'description': description, 'rating': rating, 'genre': genre, + 'custom_properties': additional_metadata if additional_metadata else None, } series_keys[series_key] = { @@ -598,7 +606,11 @@ def process_series_batch(account, batch, category_map): updated = False for field, value in series_props.items(): - if getattr(series, field) != value: + if field == 'custom_properties': + if value != series.custom_properties: + series.custom_properties = value + updated = True + elif getattr(series, field) != value: setattr(series, field, value) updated = True @@ -684,7 +696,8 @@ def process_series_batch(account, batch, category_map): # Update existing series if series_to_update: Series.objects.bulk_update(series_to_update, [ - 'description', 'rating', 'genre', 'year', 'tmdb_id', 'imdb_id', 'logo' + 'description', 'rating', 'genre', 'year', 'tmdb_id', 'imdb_id', + 'custom_properties', 'logo' ]) # Update relations to reference the correct series objects