From fca5fa05e30b57ba9ef1dde1f0a5f1e1868b527e Mon Sep 17 00:00:00 2001 From: Junwei Zhao Date: Sun, 18 Jan 2026 10:45:06 +1100 Subject: [PATCH] Remove iptv related code! --- agents.md | 3 +- data/db.sqlite3 | Bin 479232 -> 479232 bytes links/forms.py | 12 +- links/iptv_urls.py | 23 - links/iptv_views.py | 112 ---- links/migrations/0038_remove_iptv_models.py | 19 + links/models.py | 22 - .../templates/links/iptv/confirm_delete.html | 29 - .../links/iptv/confirm_delete_collection.html | 29 - links/templates/links/iptv/form.html | 57 -- links/templates/links/iptv/list.html | 549 ------------------ links/urls.py | 2 - templates/base.html | 9 - 13 files changed, 22 insertions(+), 844 deletions(-) delete mode 100644 links/iptv_urls.py delete mode 100644 links/iptv_views.py create mode 100644 links/migrations/0038_remove_iptv_models.py delete mode 100644 links/templates/links/iptv/confirm_delete.html delete mode 100644 links/templates/links/iptv/confirm_delete_collection.html delete mode 100644 links/templates/links/iptv/form.html delete mode 100644 links/templates/links/iptv/list.html diff --git a/agents.md b/agents.md index 61c0fbc..444f5d0 100644 --- a/agents.md +++ b/agents.md @@ -31,7 +31,7 @@ This guide is designed to help AI coding agents understand and work with the URL │ Django Application │ │ ┌──────────────┬──────────────┬──────────────────────┐ │ │ │ Links Module │ Pages Module │ Collections Module │ │ -│ │ │ │ (Images, IPTV, Posts)│ │ +│ │ │ │ (Images, Posts) │ │ │ └──────────────┴──────────────┴──────────────────────┘ │ │ ┌────────────────────────────────────────────────────┐ │ │ │ REST API (DRF ViewSets) │ │ @@ -512,7 +512,6 @@ links/ ├── api_views.py # REST API viewsets (Image, Music) ├── page_views.py # Page-specific views and API ├── post_views.py # Post/blog views and API -├── iptv_views.py # IPTV functionality ├── collection_views.py # Collection management ├── search_views.py # Search functionality ├── tag_views.py # Tag management diff --git a/data/db.sqlite3 b/data/db.sqlite3 index fe17d92df7a15fafa696a6123dbe860d59ce5c38..67f21b243d16eb49af20807bb096cccdc3f2c57d 100644 GIT binary patch delta 373 zcmZozAltA&c7n8EJ_7?oDG*x&u_zFqov35Xn7=V$2|u$H!_~>`0ws)BCpQX2+FIMN zGKgC{=49q&7aJHDTf`To=H{2B#%C6kl*Q-fr=;c-8yOgx=^7a78k#E@8Cw|}S{WJY z85$cJ8JKSt68ylYx0ykZFNB5vCI1!v-TYD99E3o%%2-md4t$Y|4K&}P86&47u~K%IFz10O>k11Af|Sq>Yf zZpO>3u`CxE@_3ne)c8I4WVrLV?t|cVjRdBCW){{rj8fBgCo?T&V!N?DDTS$vk%emw zQ^52OsZ1|`EXI`WchZ_p3z)4%ZGnMf2gLS3 z>;S|zKx_1 AZ2$lO delta 290 zcmZozAltA&c7n8E9s>hIDG*x&F+UKWo~UEYn71)u2|u$XqtIk_fs)Ba2GchS34Y+y zd&(fp7sA5-lK%?-ZvHadc=Ffkekvm`JGGUPFEvT&T`uwlEw`i6P?biM>8 zvF%z3Oufu3jcU>C(|0E`EoI_bvpp$=sf&@NF*AyN`iE4e7c5PQk?h;=q%mpiWMkyt z&%nQbvtYqi{_XqqnLP>^`KEI$V7BH|1^Nc$J9D7i7JdO%Ad`vzE0APx;Q!746)5_G efBKL8%sk9Kd|K`72bh7F1&CR/edit/', IPTVChannelUpdateView.as_view(), name='iptv-update'), - path('ui/iptv//delete/', IPTVChannelDeleteView.as_view(), name='iptv-delete'), - path('ui/iptv/collection//delete/', IPTVCollectionDeleteView.as_view(), name='iptv-collection-delete'), - - # API routes - path('api/iptv/export/', export_m3u_playlist, name='iptv-export'), - path('api/iptv/import/', import_m3u_playlist, name='iptv-import'), -] diff --git a/links/iptv_views.py b/links/iptv_views.py deleted file mode 100644 index 6040fc1..0000000 --- a/links/iptv_views.py +++ /dev/null @@ -1,112 +0,0 @@ -from django.urls import reverse_lazy -from django.views.generic import ListView, CreateView, UpdateView, DeleteView -from django.shortcuts import render, redirect -from django.http import HttpResponse -from django.contrib import messages -from .models import IPTVChannel, IPTVCollection -from .forms import IPTVChannelForm - -class IPTVChannelListView(ListView): - model = IPTVChannel - template_name = 'links/iptv/list.html' - context_object_name = 'channels' - - def get_context_data(self, **kwargs): - context = super().get_context_data(**kwargs) - context['collections'] = IPTVCollection.objects.all() - return context - - def get_queryset(self): - collection_id = self.request.GET.get('collection') - if collection_id: - return IPTVChannel.objects.filter(collection_id=collection_id) - return IPTVChannel.objects.all() - -class IPTVChannelCreateView(CreateView): - model = IPTVChannel - form_class = IPTVChannelForm - template_name = 'links/iptv/form.html' - success_url = reverse_lazy('iptv-list') - -class IPTVChannelUpdateView(UpdateView): - model = IPTVChannel - form_class = IPTVChannelForm - template_name = 'links/iptv/form.html' - success_url = reverse_lazy('iptv-list') - -class IPTVChannelDeleteView(DeleteView): - model = IPTVChannel - template_name = 'links/iptv/confirm_delete.html' - success_url = reverse_lazy('iptv-list') - -def export_m3u_playlist(request): - """Export all channels as M3U playlist""" - collection_id = request.GET.get('collection') - if collection_id: - channels = IPTVChannel.objects.filter(collection_id=collection_id) - collection = IPTVCollection.objects.get(id=collection_id) - filename = f"{collection.title}_channels.m3u" - else: - channels = IPTVChannel.objects.all() - filename = "all_channels.m3u" - - content = ['#EXTM3U'] - for channel in channels: - content.append(f'#EXTINF:-1 tvg-id="{channel.id}",{channel.title}') - content.append(channel.url) - - playlist_content = '\n'.join(content) - response = HttpResponse(playlist_content, content_type='audio/x-mpegurl') - response['Content-Disposition'] = f'attachment; filename="{filename}"' - return response - -def import_m3u_playlist(request): - """Import channels from M3U playlist file""" - if request.method == 'POST' and request.FILES.get('playlist'): - collection_title = request.POST.get('collection_title') - if not collection_title: - messages.error(request, 'Collection title is required') - return redirect('iptv-list') - - collection = IPTVCollection.objects.create(title=collection_title) - playlist_file = request.FILES['playlist'] - - try: - content = playlist_file.read().decode('utf-8') - lines = content.split('\n') - - current_title = None - for line in lines: - line = line.strip() - if not line: - continue - - if line.startswith('#EXTINF'): - # Extract title from EXTINF line - title_part = line.split(',', 1) - if len(title_part) > 1: - current_title = title_part[1] - else: - current_title = "Untitled Channel" - elif not line.startswith('#') and current_title: - # Create channel with URL and previous title - IPTVChannel.objects.create( - title=current_title, - url=line, - collection=collection - ) - current_title = None - - messages.success(request, f'Successfully imported channels to collection: {collection_title}') - except Exception as e: - collection.delete() - messages.error(request, f'Error importing playlist: {str(e)}') - - return redirect('iptv-list') - - return redirect('iptv-list') - -class IPTVCollectionDeleteView(DeleteView): - model = IPTVCollection - template_name = 'links/iptv/confirm_delete_collection.html' - success_url = reverse_lazy('iptv-list') diff --git a/links/migrations/0038_remove_iptv_models.py b/links/migrations/0038_remove_iptv_models.py new file mode 100644 index 0000000..6f70834 --- /dev/null +++ b/links/migrations/0038_remove_iptv_models.py @@ -0,0 +1,19 @@ +# Generated by Django 5.2.9 on 2026-01-17 23:31 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('links', '0037_linkchangelog_change_type_linkchangelog_metadata_and_more'), + ] + + operations = [ + migrations.DeleteModel( + name='IPTVChannel', + ), + migrations.DeleteModel( + name='IPTVCollection', + ), + ] diff --git a/links/models.py b/links/models.py index e79f0b8..7195a76 100644 --- a/links/models.py +++ b/links/models.py @@ -339,26 +339,4 @@ class Image(models.Model): fit='cover' ) -class IPTVCollection(models.Model): - title = models.CharField(max_length=200) - created_at = models.DateTimeField(auto_now_add=True) - updated_at = models.DateTimeField(auto_now=True) - def __str__(self): - return self.title - - class Meta: - ordering = ['-created_at'] - -class IPTVChannel(models.Model): - title = models.CharField(max_length=200) - url = models.URLField() - collection = models.ForeignKey(IPTVCollection, on_delete=models.CASCADE, related_name='channels', null=True, blank=True) - created_at = models.DateTimeField(auto_now_add=True) - updated_at = models.DateTimeField(auto_now=True) - - def __str__(self): - return self.title - - class Meta: - ordering = ['title'] diff --git a/links/templates/links/iptv/confirm_delete.html b/links/templates/links/iptv/confirm_delete.html deleted file mode 100644 index 9d5babf..0000000 --- a/links/templates/links/iptv/confirm_delete.html +++ /dev/null @@ -1,29 +0,0 @@ -{% extends "base.html" %} - -{% block content %} -
-
-
-

- Delete IPTV Channel -

-
-

Are you sure you want to delete "{{ object.title }}"? This action cannot be undone.

-
-
-
- {% csrf_token %} -
- - Cancel - - -
-
-
-
-
-
-{% endblock %} diff --git a/links/templates/links/iptv/confirm_delete_collection.html b/links/templates/links/iptv/confirm_delete_collection.html deleted file mode 100644 index a47b442..0000000 --- a/links/templates/links/iptv/confirm_delete_collection.html +++ /dev/null @@ -1,29 +0,0 @@ -{% extends "base.html" %} - -{% block content %} -
-
-
-

- Delete Collection -

-
-

Are you sure you want to delete the collection "{{ object.title }}"? This will also delete all channels in this collection.

-
-
-
- {% csrf_token %} -
- - - Cancel - -
-
-
-
-
-
-{% endblock %} diff --git a/links/templates/links/iptv/form.html b/links/templates/links/iptv/form.html deleted file mode 100644 index 783066e..0000000 --- a/links/templates/links/iptv/form.html +++ /dev/null @@ -1,57 +0,0 @@ -{% extends "base.html" %} - -{% block content %} -
-
-
-

- {% if form.instance.pk %}Edit{% else %}Add{% endif %} IPTV Channel -

-
-
- {% csrf_token %} - -
- - {{ form.title }} - {% if form.title.errors %} -

{{ form.title.errors.0 }}

- {% endif %} -
- -
- - {{ form.url }} - {% if form.url.errors %} -

{{ form.url.errors.0 }}

- {% endif %} -
- -
- - {{ form.collection }} - {% if form.collection.errors %} -

{{ form.collection.errors.0 }}

- {% endif %} -
- -
- - Cancel - - -
-
-
-
-
-
-{% endblock %} diff --git a/links/templates/links/iptv/list.html b/links/templates/links/iptv/list.html deleted file mode 100644 index 4695c0e..0000000 --- a/links/templates/links/iptv/list.html +++ /dev/null @@ -1,549 +0,0 @@ -{% extends "base.html" %} -{% load static %} - -{% block content %} -
- -
-
-
-

IPTV Channels

- - - - - -
-
- - -
-
- - -
-
- - All Channels - - {% for collection in collections %} - - {% endfor %} -
-
- - -
- {% for channel in channels %} -
-
-

{{ channel.title }}

-
- -
- {% endfor %} -
- - - - - - - - - -
- - -
-
-
- - - -

No channel selected

-

Select a channel from the list to start watching

-
- - - - - -
-
-
- - - - - - - -{% endblock %} - -{% block extra_js %} -{% endblock %} diff --git a/links/urls.py b/links/urls.py index 162ccb9..33b2ec2 100644 --- a/links/urls.py +++ b/links/urls.py @@ -69,8 +69,6 @@ urlpatterns = [ # Include collection URLs path('', include('links.collection_urls')), - # Include IPTV URLs - must be before alias patterns - path('', include('links.iptv_urls')), # Include tag URLs path('', include('links.tag_urls')), diff --git a/templates/base.html b/templates/base.html index 33dfb89..c7a2ae7 100644 --- a/templates/base.html +++ b/templates/base.html @@ -151,15 +151,6 @@ {% trans "Tags" %} - -
- - - - {% trans "IPTV" %} -
-