|
| 1 | +import os |
| 2 | +import re |
| 3 | + |
| 4 | +affiliate_text = '<strong>Affiliate disclosure:</strong> This page contains affiliate links. If you purchase via these links we may earn a commission at no extra cost to you. This helps support our research and operating costs.' |
| 5 | + |
| 6 | +# Step 1: Update all reviews in /posts |
| 7 | +directory = 'posts' |
| 8 | +for filename in os.listdir(directory): |
| 9 | + if not filename.endswith('.html'): continue |
| 10 | + filepath = os.path.join(directory, filename) |
| 11 | + with open(filepath, 'r', encoding='utf-8') as f: content = f.read() |
| 12 | + |
| 13 | + # Standardize affiliate disclosures |
| 14 | + content = re.sub(r'<p class=[\'\"]affiliate-disclosure[\'\"][^>]*>.*?</p>', f'<p class=\"affiliate-disclosure\">{affiliate_text}</p>', content, flags=re.DOTALL) |
| 15 | + content = re.sub(r'<div class=[\'\"]affiliate-disclaimer[\'\"][^>]*>.*?</div>', f'<div class=\"affiliate-disclosure\">\n {affiliate_text}\n</div>', content, flags=re.DOTALL) |
| 16 | + |
| 17 | + # For SM7B specifically, clean emojis and dashes |
| 18 | + if filename == 'shure-sm7b-review.html': |
| 19 | + content = re.sub(r'🎙️|🎛️|🏢|🔊|🎵|🔌|💰|🎒|✅|❌|✨|🚀', '', content) |
| 20 | + content = content.replace('—', ':').replace('–', '-') |
| 21 | + |
| 22 | + with open(filepath, 'w', encoding='utf-8') as f: f.write(content) |
| 23 | + |
| 24 | +# Step 2: Fix Navigation/Library Pages |
| 25 | +if os.path.exists('blog.html'): |
| 26 | + with open('blog.html', 'r', encoding='utf-8') as f: blog_content = f.read() |
| 27 | + # Find the SM7B review element and remove it |
| 28 | + blog_content = re.sub(r'<!-- Reviews -->.*?Read Review →</a>\n\s*</div>', '', blog_content, flags=re.DOTALL) |
| 29 | + with open('blog.html', 'w', encoding='utf-8') as f: f.write(blog_content) |
| 30 | + |
| 31 | +if os.path.exists('amazon-stack.html'): |
| 32 | + with open('amazon-stack.html', 'r', encoding='utf-8') as f: stack_content = f.read() |
| 33 | + if 'shure-sm7b-review.html' not in stack_content: |
| 34 | + # Create the SM7B card for Amazon Stack |
| 35 | + sm7b_card = ''' |
| 36 | + <! Shure SM7B> |
| 37 | + <div class="product-item glass-card"> |
| 38 | + <div class="product-thumbnail-wrapper"> |
| 39 | + <img src="posts/images/shure-sm7b-primary.jpg" alt="Shure SM7B dynamic studio microphone profile view thumbnail" class="product-thumbnail" loading="lazy"> |
| 40 | + </div> |
| 41 | + <div class="product-info"> |
| 42 | + <div class="product-meta">Broadcast Standard</div> |
| 43 | + <h3><a href="posts/shure-sm7b-review.html" aria-label="Open review: Shure SM7B">Shure SM7B Microphone</a></h3> |
| 44 | + <a href="posts/shure-sm7b-review.html" class="view-review-cta">View Review <i class="fa-solid fa-arrow-right"></i></a> |
| 45 | + </div> |
| 46 | + </div>''' |
| 47 | + # Insert before SM7dB |
| 48 | + stack_content = stack_content.replace('<! Shure SM7dB>', sm7b_card + '\n\n <! Shure SM7dB>') |
| 49 | + with open('amazon-stack.html', 'w', encoding='utf-8') as f: f.write(stack_content) |
| 50 | + |
| 51 | +print('Success.') |
0 commit comments