Worker
YouTubeNotificationParser
¶
Parser for YouTube PubSubHubbub notification XML data.
Attributes:
| Name | Type | Description |
|---|---|---|
namespaces |
dict
|
XML namespaces used for parsing. |
Source code in .venv/lib/python3.12/site-packages/ytindexer/worker/parser.py
parse(xml_data)
staticmethod
¶
Parse YouTube PubSubHubbub notification XML string into a YouTubeNotification model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xml_data
|
str
|
XML string of the notification. |
required |
Returns:
| Type | Description |
|---|---|
Optional[YouTubeNotification]
|
Optional[YouTubeNotification]: Parsed notification object or None if parsing fails. |
Source code in .venv/lib/python3.12/site-packages/ytindexer/worker/parser.py
YouTubeNotificationProcessor
¶
Processes YouTube PubSubHubbub notifications from the queue using the parser.
Source code in .venv/lib/python3.12/site-packages/ytindexer/worker/processor.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
process_batch(batch_size=10)
async
¶
Process a batch of notifications from the queue.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch_size
|
int
|
Number of notifications to process in a batch. |
10
|
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Number of successfully processed notifications. |
Source code in .venv/lib/python3.12/site-packages/ytindexer/worker/processor.py
process_notification(xml_data)
async
¶
Process a single YouTube notification XML.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xml_data
|
str
|
Raw XML data from the notification. |
required |
Returns:
| Type | Description |
|---|---|
Optional[Dict[str, Any]]
|
Optional[Dict[str, Any]]: Extracted video metadata if successful, otherwise None. |
Source code in .venv/lib/python3.12/site-packages/ytindexer/worker/processor.py
run(poll_interval=0.5)
async
¶
Run the worker process to continuously process notifications.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poll_interval
|
float
|
Time to wait between polling the queue. |
0.5
|