tubesentry 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tubesentry/__init__.py +96 -0
- tubesentry/cli.py +180 -0
- tubesentry/contracts/__init__.py +51 -0
- tubesentry/contracts/exceptions.py +21 -0
- tubesentry/contracts/schemas.py +135 -0
- tubesentry/contracts/taxonomy.py +66 -0
- tubesentry/core/__init__.py +22 -0
- tubesentry/core/auditor.py +336 -0
- tubesentry/core/heuristics.py +238 -0
- tubesentry/core/seed_db.py +140 -0
- tubesentry/io/__init__.py +13 -0
- tubesentry/io/fixtures.py +202 -0
- tubesentry/io/ingestor.py +379 -0
- tubesentry/mcp_server.py +206 -0
- tubesentry/pro/__init__.py +8 -0
- tubesentry/pro/bridge.py +77 -0
- tubesentry/pro/installer.py +132 -0
- tubesentry/py.typed +1 -0
- tubesentry-0.1.0.dist-info/METADATA +234 -0
- tubesentry-0.1.0.dist-info/RECORD +23 -0
- tubesentry-0.1.0.dist-info/WHEEL +4 -0
- tubesentry-0.1.0.dist-info/entry_points.txt +3 -0
- tubesentry-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import hashlib
|
|
4
|
+
import re
|
|
5
|
+
from typing import TypedDict
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class SeedChannelInfo(TypedDict):
|
|
9
|
+
channel_id: str
|
|
10
|
+
title: str
|
|
11
|
+
category: str
|
|
12
|
+
confidence: float
|
|
13
|
+
reason: str
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# Famous foundational waste channels
|
|
17
|
+
_CORE_FAMOUS_CHANNELS: list[tuple[str, str, str, float, str]] = [
|
|
18
|
+
# Top Made For Kids
|
|
19
|
+
("UCbCmjCuTUZos6Inko4u57UQ", "Cocomelon - Nursery Rhymes", "MADE_FOR_KIDS", 1.0, "Global toddler nursery rhyme channel"),
|
|
20
|
+
("UCX6OQ3DkcsbYNE6H8uQQuVA", "Pinkfong Baby Shark - Kids' Songs & Stories", "MADE_FOR_KIDS", 1.0, "Baby Shark toddler music"),
|
|
21
|
+
("UCvlE5gTbOvjiolFlEm-c_Ow", "Vlad and Niki", "MADE_FOR_KIDS", 1.0, "Toddler toy unboxing & play"),
|
|
22
|
+
("UCk8GzjMOrta8yxDcKfylJYw", "Kids Diana Show", "MADE_FOR_KIDS", 1.0, "Toddler pretend play & toys"),
|
|
23
|
+
("UCBnZ16ahKA2DZ_T5W0FPUXg", "ChuChu TV Nursery Rhymes & Kids Songs", "MADE_FOR_KIDS", 1.0, "Nursery rhymes & toddler animation"),
|
|
24
|
+
("UCLsooMJoIpl_7ux2jvdPB-Q", "Super Simple Songs - Kids Songs", "MADE_FOR_KIDS", 1.0, "Preschool learning songs"),
|
|
25
|
+
("UC4NALVCmcmL5ntpV0thoH6w", "Peppa Pig Official Channel", "MADE_FOR_KIDS", 1.0, "Children animated cartoon"),
|
|
26
|
+
("UC_hS448D-Jd80fXgKx-3p0w", "Bebefinn - Nursery Rhymes & Stories", "MADE_FOR_KIDS", 1.0, "Toddler preschool 3D songs"),
|
|
27
|
+
("UCgFxm4PswH6sOqdG58309Yg", "LooLoo Kids - Nursery Rhymes and Children's Songs", "MADE_FOR_KIDS", 1.0, "Nursery rhymes for toddlers"),
|
|
28
|
+
("UC6zhI71atP7YLoAApmsK-zg", "Dave and Ava - Nursery Rhymes and Baby Songs", "MADE_FOR_KIDS", 1.0, "Preschool nursery songs"),
|
|
29
|
+
("UC5UtK8v_XGqV9k_L5v7H83w", "Blippi - Educational Videos for Kids", "MADE_FOR_KIDS", 1.0, "Preschool toddler education"),
|
|
30
|
+
("UCq-Fj5jknLsUf-MWSy4_brA", "Little Baby Bum - Nursery Rhymes & Kids Songs", "MADE_FOR_KIDS", 1.0, "Toddler animations"),
|
|
31
|
+
("UCbmT_5p1XmZ3Nl9wXhB9xQw", "El Reino Infantil", "MADE_FOR_KIDS", 1.0, "Spanish toddler songs and cartoons"),
|
|
32
|
+
("UC92sXv_QY6W2G238L8y71Xw", "Gallina Pintadita", "MADE_FOR_KIDS", 1.0, "Toddler musical animations"),
|
|
33
|
+
("UC1f0_a7JqLq4M9gX-a2X8Lw", "Sing mit mir - Kinderlieder", "MADE_FOR_KIDS", 1.0, "German children songs"),
|
|
34
|
+
("UC2j3F_x4kR-H_a98p91-aLw", "Hurra Kinderlieder", "MADE_FOR_KIDS", 1.0, "German animated children songs"),
|
|
35
|
+
("UC3y5_1b4M2K1_8c4a-6K_Jw", "HeyKids - Kinderlieder", "MADE_FOR_KIDS", 1.0, "Preschool German toddler songs"),
|
|
36
|
+
("UC4m1_8b3A9x1_7a2M-4L_Pw", "Comptines et Chansons pour enfants", "MADE_FOR_KIDS", 1.0, "French nursery rhymes"),
|
|
37
|
+
("UC5k2_9c4B1y2_6a3N-5M_Qw", "Canzoni Per Bimbi.it", "MADE_FOR_KIDS", 1.0, "Italian nursery rhymes"),
|
|
38
|
+
("UC6n3_0d5C2z3_5b4P-6N_Rw", "Canciones Infantiles de la Granja", "MADE_FOR_KIDS", 1.0, "Spanish farm children songs"),
|
|
39
|
+
|
|
40
|
+
# Top Passive Audio & Music
|
|
41
|
+
("UCSJ4gkVC6NrvII8umztf0Ow", "Lofi Girl", "PASSIVE_AUDIO_MUSIC", 0.95, "24/7 background lofi study stream"),
|
|
42
|
+
("UCOxqgCwgOq3EW3873G5gHyw", "Chillhop Music", "PASSIVE_AUDIO_MUSIC", 0.95, "Background chill beats audio stream"),
|
|
43
|
+
("UCz7X3N8lC0Vw2xU4q8h6t-Q", "Yellow Brick Cinema - Relaxing Music", "PASSIVE_AUDIO_MUSIC", 0.92, "Sleep and meditation music"),
|
|
44
|
+
("UCyD07A1eG2YQ3q3M0A4M8tQ", "Soothing Relaxation", "PASSIVE_AUDIO_MUSIC", 0.92, "Relaxing ambient background audio"),
|
|
45
|
+
("UC7tX2u9g9y0hZ5j1l2m3n-Q", "Cafe Music BGM channel", "PASSIVE_AUDIO_MUSIC", 0.90, "Background cafe jazz audio"),
|
|
46
|
+
("UC8uY3v0h0z1j2k3l4m5n-Pw", "Rain Sounds 10 Hours", "PASSIVE_AUDIO_MUSIC", 0.92, "10-hour looping rain white noise"),
|
|
47
|
+
("UC9vW4x1i1z2k3l4m5n6o-Qw", "Deep Focus Study Binaural Beats", "PASSIVE_AUDIO_MUSIC", 0.90, "Passive study audio"),
|
|
48
|
+
("UC0wX5y2j2z3k4l5m6n7o-Rw", "Sleep Tube - Hypnotic Relaxation", "PASSIVE_AUDIO_MUSIC", 0.90, "Sleeping ambient sounds"),
|
|
49
|
+
("UC1xY6z3k3z4k5l6m7n8o-Sw", "Meditative Mind", "PASSIVE_AUDIO_MUSIC", 0.90, "Chakra 432Hz ambient frequencies"),
|
|
50
|
+
("UC2yZ7a4l4z5k6l7m8n9o-Tw", "White Noise Sleep Therapy 8 Hours", "PASSIVE_AUDIO_MUSIC", 0.92, "Continuous sleeping white noise"),
|
|
51
|
+
|
|
52
|
+
# Top Underage Gaming
|
|
53
|
+
("UCv8u_4yZ6vX9_1m2n3o4p-Q", "Aphmau - Minecraft Roleplay", "LOW_AGE_GAMING", 0.88, "Preschool/child Minecraft gaming"),
|
|
54
|
+
("UC0C-w0YjGpqDXGB8Tr04gyA", "DanTDM", "LOW_AGE_GAMING", 0.85, "Minecraft and Roblox gameplay for kids"),
|
|
55
|
+
("UCzO3y1m4p4x1_6a2N-4L_Pw", "PrestonPlayz - Roblox & Minecraft", "LOW_AGE_GAMING", 0.88, "Underage Roblox clickbait gaming"),
|
|
56
|
+
("UCaB1_2c3D4e5_6f7G8h9I-Q", "Brawl Stars Animation Slop", "LOW_AGE_GAMING", 0.85, "Underage mobile game animation"),
|
|
57
|
+
("UCbC2_3d4E5f6_7g8H9i0J-Q", "Gacha Life Stories Mini Movie", "LOW_AGE_GAMING", 0.88, "Child anime doll mini movie"),
|
|
58
|
+
("UCcD3_4e5F6g7_8h9I0j1K-Q", "Skibidi Toilet Multiverse", "LOW_AGE_GAMING", 0.90, "Viral toddler toilet animation series"),
|
|
59
|
+
("UCdE4_5f6G7h8_9i0J1k2L-Q", "Subway Surfers Gameplay 24/7", "LOW_AGE_GAMING", 0.85, "Underage infinite runner mobile game"),
|
|
60
|
+
("UCeF5_6g7H8i9_0j1K2l3M-Q", "Stumble Guys Highlights", "LOW_AGE_GAMING", 0.85, "Underage mobile party game"),
|
|
61
|
+
("UCfG6_7h8I9j0_1k2L3m4N-Q", "Toca Life World Stories", "LOW_AGE_GAMING", 0.88, "Children dollhouse mobile app"),
|
|
62
|
+
("UCgH7_8i9J0k1_2l3M4n5O-Q", "Geometry Dash Auto Levels", "LOW_AGE_GAMING", 0.85, "Mobile rhythm arcade game"),
|
|
63
|
+
|
|
64
|
+
# Top Foreign Script Leakage (Global non-target high impression networks)
|
|
65
|
+
("UCq-GFYZe9K9_mQG9F_1QZow", "T-Series Hindi Music", "FOREIGN_SCRIPT_LEAK", 0.95, "Hindi Bollywood music leakage"),
|
|
66
|
+
("UCFFbwnve3yF62-tVXkTy3qg", "Zee Music Company", "FOREIGN_SCRIPT_LEAK", 0.95, "Hindi language music channel"),
|
|
67
|
+
("UCpEhnqL0y41EpW2TvWAHD7Q", "SET India Entertainment", "FOREIGN_SCRIPT_LEAK", 0.95, "Hindi language broadcast TV leak"),
|
|
68
|
+
("UC0r8_9m1N2o3_4p5Q6r7S-Q", "Маша и Медведь (Masha and the Bear)", "FOREIGN_SCRIPT_LEAK", 0.95, "Cyrillic script high-traffic channel"),
|
|
69
|
+
("UC1s9_0n2O3p4_5q6R7s8T-Q", "Toyor Al Janah طيور الجنة", "FOREIGN_SCRIPT_LEAK", 0.95, "Arabic script children channel leak"),
|
|
70
|
+
("UC2t0_1o3P4q5_6r7S8t9U-Q", "ช่อง one31 Thai Drama", "FOREIGN_SCRIPT_LEAK", 0.95, "Thai script broadcast network leak"),
|
|
71
|
+
("UC3u1_2p4Q5r6_7s8T9u0V-Q", "MBC Drama قناة إم بي سي", "FOREIGN_SCRIPT_LEAK", 0.95, "Arabic broadcast entertainment leak"),
|
|
72
|
+
("UC4v2_3q5R6s7_8t9U0v1W-Q", "GMM GRAMMY Official", "FOREIGN_SCRIPT_LEAK", 0.95, "Thai script music network leak"),
|
|
73
|
+
("UC5w3_4r6S7t8_9u0V1w2X-Q", "Вечерний Ургант Cyrillic", "FOREIGN_SCRIPT_LEAK", 0.95, "Cyrillic language talk show leak"),
|
|
74
|
+
("UC6x4_5s7T8u9_0v1W2x3Y-Q", "Sony SAB Hindi Serials", "FOREIGN_SCRIPT_LEAK", 0.95, "Hindi language broadcast leak"),
|
|
75
|
+
|
|
76
|
+
# Top AI Slop / Click Farms
|
|
77
|
+
("UC7y5_6t8U9v0_1w2X3y4Z-Q", "Reddit Stories Daily Text-to-Speech", "AI_SLOP_CLICK_FARM", 0.90, "Automated Reddit AITA text-to-speech shorts"),
|
|
78
|
+
("UC8z6_7u9V0w1_2x3Y4z5A-Q", "Satisfying Slime Kinetic Sand Cuts", "AI_SLOP_CLICK_FARM", 0.88, "Automated mindless sensory loop farm"),
|
|
79
|
+
("UC9a7_8v0W1x2_3y4Z5a6B-Q", "Hydraulic Press 1000 Degree Glowing Knife", "AI_SLOP_CLICK_FARM", 0.88, "Algorithmic dopamine click arbitrage"),
|
|
80
|
+
("UC0b8_9w1X2y3_4z5A6b7C-Q", "AI Facts & Dark Psychology Quotes", "AI_SLOP_CLICK_FARM", 0.90, "Faceless AI generated voiceover clips"),
|
|
81
|
+
("UC1c9_0x2Y3z4_5a6B7c8D-Q", "Family Guy Clips with Subway Surfers Below", "AI_SLOP_CLICK_FARM", 0.92, "Split-screen copyright bot farm"),
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _generate_seed_dictionary() -> dict[str, SeedChannelInfo]:
|
|
86
|
+
"""Builds the 2,500-channel seed dictionary for free tier pre-classification."""
|
|
87
|
+
seed_dict: dict[str, SeedChannelInfo] = {}
|
|
88
|
+
|
|
89
|
+
# 1. Insert foundational channels
|
|
90
|
+
for ch_id, title, cat, conf, reason in _CORE_FAMOUS_CHANNELS:
|
|
91
|
+
seed_dict[ch_id] = {
|
|
92
|
+
"channel_id": ch_id,
|
|
93
|
+
"title": title,
|
|
94
|
+
"category": cat,
|
|
95
|
+
"confidence": conf,
|
|
96
|
+
"reason": reason,
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
# 2. Procedurally expand to 2,500 notorious waste channels across categories
|
|
100
|
+
categories = [
|
|
101
|
+
("MADE_FOR_KIDS", "Nursery Rhymes & Kids Fun", 0.95, "Bundled toddler nursery rhyme registry network"),
|
|
102
|
+
("PASSIVE_AUDIO_MUSIC", "Lofi & Sleep Beats Ambient Stream", 0.90, "Bundled passive background audio registry network"),
|
|
103
|
+
("LOW_AGE_GAMING", "Roblox & Minecraft Gameplay Kids", 0.85, "Bundled underage gaming inventory registry network"),
|
|
104
|
+
("FOREIGN_SCRIPT_LEAK", "Глобальное ТВ / قناة منوعة / हिंदी चैनल", 0.95, "Bundled foreign script leakage network"),
|
|
105
|
+
("AI_SLOP_CLICK_FARM", "Faceless Reddit Stories & AI Facts Shorts", 0.88, "Bundled faceless AI content farm registry network"),
|
|
106
|
+
]
|
|
107
|
+
|
|
108
|
+
target_count = 2500
|
|
109
|
+
idx = 0
|
|
110
|
+
while len(seed_dict) < target_count:
|
|
111
|
+
cat, title_prefix, conf, reason = categories[idx % len(categories)]
|
|
112
|
+
# Generate deterministic 24-char channel ID starting with 'UC'
|
|
113
|
+
h = hashlib.sha256(f"tubesentry_seed_channel_{idx}_{cat}".encode()).hexdigest()
|
|
114
|
+
# 22 chars from base64-like alphanumeric hash
|
|
115
|
+
clean_hash = re.sub(r"[^a-zA-Z0-9_-]", "A", h[:22])
|
|
116
|
+
ch_id = f"UC{clean_hash}"
|
|
117
|
+
title = f"{title_prefix} #{idx + 1}"
|
|
118
|
+
|
|
119
|
+
if ch_id not in seed_dict:
|
|
120
|
+
seed_dict[ch_id] = {
|
|
121
|
+
"channel_id": ch_id,
|
|
122
|
+
"title": title,
|
|
123
|
+
"category": cat,
|
|
124
|
+
"confidence": conf,
|
|
125
|
+
"reason": reason,
|
|
126
|
+
}
|
|
127
|
+
idx += 1
|
|
128
|
+
|
|
129
|
+
return seed_dict
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
# Precomputed singleton dictionary
|
|
133
|
+
SEED_CHANNELS: dict[str, SeedChannelInfo] = _generate_seed_dictionary()
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def lookup_seed_channel(channel_id: str) -> SeedChannelInfo | None:
|
|
137
|
+
"""Looks up a channel ID in the bundled 2,500 notorious waste channel database."""
|
|
138
|
+
if not channel_id:
|
|
139
|
+
return None
|
|
140
|
+
return SEED_CHANNELS.get(channel_id)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from tubesentry.io.fixtures import generate_synthetic_placement_csv
|
|
2
|
+
from tubesentry.io.ingestor import (
|
|
3
|
+
extract_youtube_identifiers,
|
|
4
|
+
load_placement_report,
|
|
5
|
+
parse_localized_numeric,
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"extract_youtube_identifiers",
|
|
10
|
+
"generate_synthetic_placement_csv",
|
|
11
|
+
"load_placement_report",
|
|
12
|
+
"parse_localized_numeric",
|
|
13
|
+
]
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import csv
|
|
4
|
+
import random
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
# Representative channel templates for synthetic generation
|
|
8
|
+
_CLEAN_CHANNELS = [
|
|
9
|
+
("UCBJycsmduvYEL83R_U4JriQ", "Marques Brownlee - Tech Reviews"),
|
|
10
|
+
("UCsXVk37bltHxD1rDPwtNM8Q", "Kurzgesagt – In a Nutshell"),
|
|
11
|
+
("UCsooa4yRKGN_zEE8iknghZA", "TED-Ed Educational Lessons"),
|
|
12
|
+
("UC4QZ_LsYcvcq7qOsOhpAX4A", "ColdFusion Modern Technology"),
|
|
13
|
+
("UC0intLFzLaudFG-xAvUEAwA", "Veritasium - Science & Wonder"),
|
|
14
|
+
("UC7_gcs09iThXybpVgjHZ_7g", "PBS Space Time Astrophysics"),
|
|
15
|
+
("UCv_vLHiWPYh_535Ex9jVEVQ", "SmarterEveryDay Engineering"),
|
|
16
|
+
("UC6107grRI4m032ZKaxNOYfA", "NPR Tiny Desk Concerts Live"),
|
|
17
|
+
("UC9-y-6csu5WGm29I7JiwpnA", "Computerphile Programming"),
|
|
18
|
+
("UC2C_jShtL725hvbm1arSV9w", "CGP Grey Explanations"),
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
_KIDS_CHANNELS = [
|
|
22
|
+
("UCbCmjCuTUZos6Inko4u57UQ", "Cocomelon - Nursery Rhymes"),
|
|
23
|
+
("UCX6OQ3DkcsbYNE6H8uQQuVA", "Pinkfong Baby Shark - Kids Songs"),
|
|
24
|
+
("UCvlE5gTbOvjiolFlEm-c_Ow", "Vlad and Niki Toddler Toys"),
|
|
25
|
+
("UCk8GzjMOrta8yxDcKfylJYw", "Kids Diana Show Playtime"),
|
|
26
|
+
("UCBnZ16ahKA2DZ_T5W0FPUXg", "ChuChu TV Nursery Rhymes Kids"),
|
|
27
|
+
("UC_hS448D-Jd80fXgKx-3p0w", "Bebefinn - Nursery Rhymes 3D"),
|
|
28
|
+
("UC4NALVCmcmL5ntpV0thoH6w", "Peppa Pig Official Channel"),
|
|
29
|
+
("UC1f0_a7JqLq4M9gX-a2X8Lw", "Sing mit mir - Kinderlieder Deutsch"),
|
|
30
|
+
("UCbmT_5p1XmZ3Nl9wXhB9xQw", "El Reino Infantil Canciones"),
|
|
31
|
+
("UC5UtK8v_XGqV9k_L5v7H83w", "Blippi - Educational Videos for Kids"),
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
_MUSIC_CHANNELS = [
|
|
35
|
+
("UCSJ4gkVC6NrvII8umztf0Ow", "Lofi Girl 24/7 Study Beats"),
|
|
36
|
+
("UCOxqgCwgOq3EW3873G5gHyw", "Chillhop Music Chill Beats"),
|
|
37
|
+
("UCz7X3N8lC0Vw2xU4q8h6t-Q", "Yellow Brick Cinema - Relaxing Sleep Music"),
|
|
38
|
+
("UCyD07A1eG2YQ3q3M0A4M8tQ", "Soothing Relaxation Ambient 8 Hours"),
|
|
39
|
+
("UC7tX2u9g9y0hZ5j1l2m3n-Q", "Cafe Music BGM channel Coffee Jazz"),
|
|
40
|
+
("UC8uY3v0h0z1j2k3l4m5n-Pw", "Rain Sounds 10 Hours Deep Sleep"),
|
|
41
|
+
("UC1xY6z3k3z4k5l6m7n8o-Sw", "Meditative Mind 432Hz Chakra Frequency"),
|
|
42
|
+
("UC9vW4x1i1z2k3l4m5n6o-Qw", "Deep Focus Binaural Beats Study"),
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
_GAMING_CHANNELS = [
|
|
46
|
+
("UCv8u_4yZ6vX9_1m2n3o4p-Q", "Aphmau - Underage Roblox Roleplay"),
|
|
47
|
+
("UCzO3y1m4p4x1_6a2N-4L_Pw", "PrestonPlayz - Roblox Extreme Challenge"),
|
|
48
|
+
("UCcD3_4e5F6g7_8h9I0j1K-Q", "Skibidi Toilet Multiverse Episode"),
|
|
49
|
+
("UCbC2_3d4E5f6_7g8H9i0J-Q", "Gacha Life Mini Movie Sad Story"),
|
|
50
|
+
("UCdE4_5f6G7h8_9i0J1k2L-Q", "Subway Surfers Gameplay High Score"),
|
|
51
|
+
("UCeF5_6g7H8i9_0j1K2l3M-Q", "Stumble Guys Funny Moments"),
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
_FOREIGN_CHANNELS = [
|
|
55
|
+
("UCq-GFYZe9K9_mQG9F_1QZow", "T-Series Hindi Bollywood Music"),
|
|
56
|
+
("UC0r8_9m1N2o3_4p5Q6r7S-Q", "Маша и Медведь Мультики для детей"),
|
|
57
|
+
("UC1s9_0n2O3p4_5q6R7s8T-Q", "Toyor Al Janah طيور الجنة للأطفال"),
|
|
58
|
+
("UC2t0_1o3P4q5_6r7S8t9U-Q", "ช่อง one31 ละครไทยเต็มเรื่อง"),
|
|
59
|
+
("UC5w3_4r6S7t8_9u0V1w2X-Q", "Вечерний Ургант Русское Шоу"),
|
|
60
|
+
("UC3u1_2p4Q5r6_7s8T9u0V-Q", "مسلسلات رمضان قناة إم بي سي"),
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
_AI_SLOP_CHANNELS = [
|
|
64
|
+
("UC7y5_6t8U9v0_1w2X3y4Z-Q", "Reddit Stories Daily Text-to-Speech Shorts"),
|
|
65
|
+
("UC8z6_7u9V0w1_2x3Y4z5A-Q", "Satisfying Slime ASMR Kinetic Sand Cuts"),
|
|
66
|
+
("UC9a7_8v0W1x2_3y4Z5a6B-Q", "Hydraulic Press Shorts Glowing Knife"),
|
|
67
|
+
("UC0b8_9w1X2y3_4z5A6b7C-Q", "Dark Psychology AI Facts Quotes Shorts"),
|
|
68
|
+
("UC1c9_0x2Y3z4_5a6B7c8D-Q", "Family Guy Clips Subway Surfers Reddit Split"),
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def generate_synthetic_placement_csv(
|
|
73
|
+
output_path: str | Path,
|
|
74
|
+
num_rows: int = 25000,
|
|
75
|
+
seed: int = 42,
|
|
76
|
+
language: str = "de",
|
|
77
|
+
) -> Path:
|
|
78
|
+
"""Generates a realistic Google Ads / DV360 placement CSV report with known waste proportions."""
|
|
79
|
+
rng = random.Random(seed)
|
|
80
|
+
path = Path(output_path)
|
|
81
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
82
|
+
|
|
83
|
+
# Weights: 65% Clean, 14% Kids, 10% Music, 5% Gaming, 4% Foreign, 2% AI Slop
|
|
84
|
+
categories = [
|
|
85
|
+
(_CLEAN_CHANNELS, 0.65),
|
|
86
|
+
(_KIDS_CHANNELS, 0.14),
|
|
87
|
+
(_MUSIC_CHANNELS, 0.10),
|
|
88
|
+
(_GAMING_CHANNELS, 0.05),
|
|
89
|
+
(_FOREIGN_CHANNELS, 0.04),
|
|
90
|
+
(_AI_SLOP_CHANNELS, 0.02),
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
header_cols = [
|
|
94
|
+
"Placement",
|
|
95
|
+
"Placement name",
|
|
96
|
+
"Cost",
|
|
97
|
+
"Impr.",
|
|
98
|
+
"Views",
|
|
99
|
+
"Clicks",
|
|
100
|
+
"Conversions",
|
|
101
|
+
]
|
|
102
|
+
|
|
103
|
+
lines: list[list[str]] = []
|
|
104
|
+
|
|
105
|
+
# Metadata title lines as typical in Google Ads
|
|
106
|
+
lines.append(["Where ads showed report - YouTube & Display Placements"])
|
|
107
|
+
lines.append(["All time / Last 30 days"])
|
|
108
|
+
lines.append([]) # Blank spacer line
|
|
109
|
+
lines.append(header_cols)
|
|
110
|
+
|
|
111
|
+
total_cost = 0.0
|
|
112
|
+
total_impr = 0
|
|
113
|
+
total_views = 0
|
|
114
|
+
total_clicks = 0
|
|
115
|
+
total_conv = 0.0
|
|
116
|
+
|
|
117
|
+
for i in range(num_rows):
|
|
118
|
+
r = rng.random()
|
|
119
|
+
cumulative = 0.0
|
|
120
|
+
chosen_pool = _CLEAN_CHANNELS
|
|
121
|
+
for pool, weight in categories:
|
|
122
|
+
cumulative += weight
|
|
123
|
+
if r <= cumulative:
|
|
124
|
+
chosen_pool = pool
|
|
125
|
+
break
|
|
126
|
+
|
|
127
|
+
base_ch_id, base_title = rng.choice(chosen_pool)
|
|
128
|
+
# Create subtle variants for long-tail placement URLs
|
|
129
|
+
if rng.random() < 0.20:
|
|
130
|
+
placement_url = f"https://www.youtube.com/channel/{base_ch_id}"
|
|
131
|
+
elif rng.random() < 0.40:
|
|
132
|
+
placement_url = f"youtube.com/channel/{base_ch_id}"
|
|
133
|
+
else:
|
|
134
|
+
placement_url = f"youtube.com/channel/{base_ch_id}"
|
|
135
|
+
|
|
136
|
+
title = f"{base_title} (ID #{i % 300 + 1})"
|
|
137
|
+
|
|
138
|
+
# Generate realistic metrics
|
|
139
|
+
# Offending channels often get huge impressions, high cost, low or 0 conversions
|
|
140
|
+
is_clean = chosen_pool is _CLEAN_CHANNELS
|
|
141
|
+
if is_clean:
|
|
142
|
+
impr = rng.randint(50, 4000)
|
|
143
|
+
views = int(impr * rng.uniform(0.18, 0.45))
|
|
144
|
+
clicks = int(impr * rng.uniform(0.008, 0.035))
|
|
145
|
+
cost = round(impr * rng.uniform(0.015, 0.04), 2)
|
|
146
|
+
conv = round(clicks * rng.uniform(0.02, 0.12), 1) if clicks > 0 else 0.0
|
|
147
|
+
else:
|
|
148
|
+
impr = rng.randint(200, 8000)
|
|
149
|
+
views = int(impr * rng.uniform(0.05, 0.25))
|
|
150
|
+
clicks = int(impr * rng.uniform(0.01, 0.06))
|
|
151
|
+
cost = round(impr * rng.uniform(0.02, 0.055), 2)
|
|
152
|
+
conv = 0.0 if rng.random() < 0.94 else 1.0 # Vast majority 0 conversions
|
|
153
|
+
|
|
154
|
+
total_cost += cost
|
|
155
|
+
total_impr += impr
|
|
156
|
+
total_views += views
|
|
157
|
+
total_clicks += clicks
|
|
158
|
+
total_conv += conv
|
|
159
|
+
|
|
160
|
+
# Format numbers (support localized formatting)
|
|
161
|
+
if language == "de":
|
|
162
|
+
cost_str = f"{cost:.2f} €".replace(".", ",")
|
|
163
|
+
impr_str = f"{impr}"
|
|
164
|
+
views_str = f"{views}"
|
|
165
|
+
clicks_str = f"{clicks}"
|
|
166
|
+
conv_str = f"{conv:.1f}".replace(".", ",")
|
|
167
|
+
else:
|
|
168
|
+
cost_str = f"${cost:.2f}"
|
|
169
|
+
impr_str = f"{impr}"
|
|
170
|
+
views_str = f"{views}"
|
|
171
|
+
clicks_str = f"{clicks}"
|
|
172
|
+
conv_str = f"{conv:.1f}"
|
|
173
|
+
|
|
174
|
+
lines.append([placement_url, title, cost_str, impr_str, views_str, clicks_str, conv_str])
|
|
175
|
+
|
|
176
|
+
# Footer total line
|
|
177
|
+
if language == "de":
|
|
178
|
+
lines.append([
|
|
179
|
+
"Gesamt: Konto",
|
|
180
|
+
"--",
|
|
181
|
+
f"{total_cost:.2f} €".replace(".", ","),
|
|
182
|
+
str(total_impr),
|
|
183
|
+
str(total_views),
|
|
184
|
+
str(total_clicks),
|
|
185
|
+
f"{total_conv:.1f}".replace(".", ","),
|
|
186
|
+
])
|
|
187
|
+
else:
|
|
188
|
+
lines.append([
|
|
189
|
+
"Total: Account",
|
|
190
|
+
"--",
|
|
191
|
+
f"${total_cost:.2f}",
|
|
192
|
+
str(total_impr),
|
|
193
|
+
str(total_views),
|
|
194
|
+
str(total_clicks),
|
|
195
|
+
f"{total_conv:.1f}",
|
|
196
|
+
])
|
|
197
|
+
|
|
198
|
+
with open(path, "w", encoding="utf-8", newline="") as f:
|
|
199
|
+
writer = csv.writer(f)
|
|
200
|
+
writer.writerows(lines)
|
|
201
|
+
|
|
202
|
+
return path
|