Generate programs using custom dummy EPG regex patterns. Extracts information from channel title using regex patterns and generates programs based on the extracted data. TIMEZONE HANDLING: ------------------ The timezone parameter specifies the timezone of the event times
(
channel_id,
channel_name,
now,
num_days,
custom_properties,
export_lookback=None,
export_cutoff=None,
)
| 255 | |
| 256 | |
| 257 | def generate_custom_dummy_programs( |
| 258 | channel_id, |
| 259 | channel_name, |
| 260 | now, |
| 261 | num_days, |
| 262 | custom_properties, |
| 263 | export_lookback=None, |
| 264 | export_cutoff=None, |
| 265 | ): |
| 266 | """ |
| 267 | Generate programs using custom dummy EPG regex patterns. |
| 268 | |
| 269 | Extracts information from channel title using regex patterns and generates |
| 270 | programs based on the extracted data. |
| 271 | |
| 272 | TIMEZONE HANDLING: |
| 273 | ------------------ |
| 274 | The timezone parameter specifies the timezone of the event times in your channel |
| 275 | titles using standard timezone names (e.g., 'US/Eastern', 'US/Pacific', 'Europe/London'). |
| 276 | DST (Daylight Saving Time) is handled automatically by pytz. |
| 277 | |
| 278 | Examples: |
| 279 | - Channel: "NHL 01: Bruins VS Maple Leafs @ 8:00PM ET" |
| 280 | - Set timezone = "US/Eastern" |
| 281 | - In October (DST): 8:00PM EDT → 12:00AM UTC (automatically uses UTC-4) |
| 282 | - In January (no DST): 8:00PM EST → 1:00AM UTC (automatically uses UTC-5) |
| 283 | |
| 284 | Args: |
| 285 | channel_id: Channel ID for the programs |
| 286 | channel_name: Channel title to parse |
| 287 | now: Current datetime (in UTC) |
| 288 | num_days: Number of days to generate programs for |
| 289 | custom_properties: Dict with title_pattern, time_pattern, templates, etc. |
| 290 | - timezone: Timezone name (e.g., 'US/Eastern') |
| 291 | |
| 292 | Returns: |
| 293 | List of program dictionaries with start_time/end_time in UTC |
| 294 | """ |
| 295 | import pytz |
| 296 | |
| 297 | logger.info(f"Generating custom dummy programs for channel: {channel_name}") |
| 298 | |
| 299 | # Extract patterns from custom properties |
| 300 | title_pattern = custom_properties.get('title_pattern', '') |
| 301 | time_pattern = custom_properties.get('time_pattern', '') |
| 302 | date_pattern = custom_properties.get('date_pattern', '') |
| 303 | |
| 304 | # Get timezone name (e.g., 'US/Eastern', 'US/Pacific', 'Europe/London') |
| 305 | timezone_value = custom_properties.get('timezone', 'UTC') |
| 306 | output_timezone_value = custom_properties.get('output_timezone', '') # Optional: display times in different timezone |
| 307 | program_duration = custom_properties.get('program_duration', 180) # Minutes |
| 308 | title_template = custom_properties.get('title_template', '') |
| 309 | subtitle_template = custom_properties.get('subtitle_template', '') |
| 310 | description_template = custom_properties.get('description_template', '') |
| 311 | |
| 312 | # Templates for upcoming/ended programs |
| 313 | upcoming_title_template = custom_properties.get('upcoming_title_template', '') |
| 314 | upcoming_description_template = custom_properties.get('upcoming_description_template', '') |
no test coverage detected