| 13 | |
| 14 | |
| 15 | class M3UAccount(models.Model): |
| 16 | class Types(models.TextChoices): |
| 17 | STADNARD = "STD", "Standard" |
| 18 | XC = "XC", "Xtream Codes" |
| 19 | |
| 20 | class Status(models.TextChoices): |
| 21 | IDLE = "idle", "Idle" |
| 22 | FETCHING = "fetching", "Fetching" |
| 23 | PARSING = "parsing", "Parsing" |
| 24 | ERROR = "error", "Error" |
| 25 | SUCCESS = "success", "Success" |
| 26 | PENDING_SETUP = "pending_setup", "Pending Setup" |
| 27 | DISABLED = "disabled", "Disabled" |
| 28 | |
| 29 | """Represents an M3U Account for IPTV streams.""" |
| 30 | name = models.CharField( |
| 31 | max_length=255, unique=True, help_text="Unique name for this M3U account" |
| 32 | ) |
| 33 | server_url = models.URLField( |
| 34 | max_length=1000, |
| 35 | blank=True, |
| 36 | null=True, |
| 37 | help_text="The base URL of the M3U server (optional if a file is uploaded)", |
| 38 | ) |
| 39 | file_path = models.CharField(max_length=255, blank=True, null=True) |
| 40 | server_group = models.ForeignKey( |
| 41 | "ServerGroup", |
| 42 | on_delete=models.SET_NULL, |
| 43 | null=True, |
| 44 | blank=True, |
| 45 | related_name="m3u_accounts", |
| 46 | help_text="The server group this M3U account belongs to", |
| 47 | ) |
| 48 | max_streams = models.PositiveIntegerField( |
| 49 | default=0, help_text="Maximum number of concurrent streams (0 for unlimited)" |
| 50 | ) |
| 51 | is_active = models.BooleanField( |
| 52 | default=True, help_text="Set to false to deactivate this M3U account" |
| 53 | ) |
| 54 | created_at = models.DateTimeField( |
| 55 | auto_now_add=True, help_text="Time when this account was created" |
| 56 | ) |
| 57 | updated_at = models.DateTimeField( |
| 58 | null=True, |
| 59 | blank=True, |
| 60 | help_text="Time when this account was last successfully refreshed", |
| 61 | ) |
| 62 | status = models.CharField( |
| 63 | max_length=20, choices=Status.choices, default=Status.IDLE |
| 64 | ) |
| 65 | last_message = models.TextField( |
| 66 | null=True, |
| 67 | blank=True, |
| 68 | help_text="Last status message, including success results or error information", |
| 69 | ) |
| 70 | user_agent = models.ForeignKey( |
| 71 | "core.UserAgent", |
| 72 | on_delete=models.SET_NULL, |