David Blume commited on 2019-10-10 22:51:50
Showing 2 changed files, with 14 additions and 11 deletions.
... | ... |
@@ -22,7 +22,7 @@ With that data, the service would determine the median, mean, standard |
22 | 22 |
deviation, and create a minimum threshold for whether the article merited |
23 | 23 |
being seen by me. |
24 | 24 |
|
25 |
-I go into deeper detail in this [blog post about it](http://david.dlma.com/blog/my-techcrunch-feed-filter). |
|
25 |
+I go into deeper detail in this [blog post about it](https://david.dlma.com/blog/my-techcrunch-feed-filter). |
|
26 | 26 |
|
27 | 27 |
Here's [the status page it generates](http://techcrunch.dlma.com/). |
28 | 28 |
|
... | ... |
@@ -50,4 +50,4 @@ site. |
50 | 50 |
|
51 | 51 |
# Licence |
52 | 52 |
|
53 |
-This software uses the [MIT license](http://git.dlma.com/techcrunch.git/blob/master/LICENSE.txt) |
|
53 |
+This software uses the [MIT license](http://git.dlma.com/techcrunch.git/blob/master/LICENSE.txt). |
... | ... |
@@ -44,7 +44,8 @@ html_head = """<!DOCTYPE html> |
44 | 44 |
<link rel="alternate" type="application/rss+xml" title="RSS feed" href="http://feeds.feedburner.com/TrendingAtTechcrunch" /> |
45 | 45 |
<style type="text/css"> |
46 | 46 |
body { font-family: "Arial", san-serif; } |
47 |
- .author { font-size: smaller; } |
|
47 |
+ .author { font-size: smaller; color:gray; } |
|
48 |
+ .date { font-size: smaller; color:gray; } |
|
48 | 49 |
.h3 { font-size: larger; } |
49 | 50 |
a { text-decoration: none; } |
50 | 51 |
/* table { border: none; border-collapse:collapse; font-size: large } */ |
... | ... |
@@ -62,7 +63,7 @@ html_head = """<!DOCTYPE html> |
62 | 63 |
google.charts.setOnLoadCallback(drawChart); |
63 | 64 |
function drawChart() { |
64 | 65 |
var options = { |
65 |
- width:300, |
|
66 |
+ width:%d, |
|
66 | 67 |
height:68, |
67 | 68 |
pointSize:0.1, |
68 | 69 |
dataOpacity:1.0, |
... | ... |
@@ -100,7 +101,7 @@ chart_data_middle = """ ]); |
100 | 101 |
options.backgroundColor = '#%s'; |
101 | 102 |
""" |
102 | 103 |
|
103 |
-img_width = 300 |
|
104 |
+img_width = 240 |
|
104 | 105 |
img_height = 68 |
105 | 106 |
|
106 | 107 |
series_1_color = "0000FF" |
... | ... |
@@ -457,7 +458,7 @@ def make_index_html(yaml_items, weekend_stats, weekday_stats): |
457 | 458 |
) |
458 | 459 |
|
459 | 460 |
with codecs.open(new_index_fullpath, 'w', 'utf-8') as f: |
460 |
- f.write(html_head % (even_background, odd_background, chart_io.getvalue())) |
|
461 |
+ f.write(html_head % (even_background, odd_background, img_width, chart_io.getvalue())) |
|
461 | 462 |
chart_io.close() |
462 | 463 |
f.write('<div align="center">\n<table class="legend">\n<tr><th></th><th>Median</th><th>Mean</th><th>Std. Dev</th><th>Threshold</th></tr>\n') |
463 | 464 |
f.write('<tr><th>Weekday</th><td>%1.1f</td><td>%1.1f</td><td>%1.1f</td><td>%1.1f</td></tr>\n' % (weekday_stats[2][0], weekday_stats[2][1], weekday_stats[2][2], weekday_stats[2][1] + weekday_stats[2][2])) |
... | ... |
@@ -465,10 +466,11 @@ def make_index_html(yaml_items, weekend_stats, weekday_stats): |
465 | 466 |
f.write('</table></div>\n<br />\n') |
466 | 467 |
f.write('<div align="center">\n<table>\n') |
467 | 468 |
for image_index, image in enumerate(yaml_items[:40]): |
468 |
- f.write('<tr valign="center" class="%s">\n <td><strong><a href="%s">%s</a></strong> <span class="author">by %s</span></td>\n' % \ |
|
469 |
+ f.write('<tr valign="center" class="%s">\n <td><strong><a href="%s">%s</a></strong> <span class="date">at %s</span> <span class="author">by %s</span></td>\n' % \ |
|
469 | 470 |
(image_index % 2 and "even" or "odd", |
470 | 471 |
image['link'], |
471 | 472 |
image['title'].encode('ascii', 'xmlcharrefreplace'), |
473 |
+ time.strftime("%H:%M", time.localtime(image['orig_posted'])).encode('ascii', 'xmlcharrefreplace'), |
|
472 | 474 |
image['author'].encode('ascii', 'xmlcharrefreplace'), |
473 | 475 |
) |
474 | 476 |
) |
... | ... |
@@ -484,7 +486,7 @@ def make_index_html(yaml_items, weekend_stats, weekday_stats): |
484 | 486 |
def make_feed_file(yaml_items): |
485 | 487 |
"""Writes the RSS feed file with the YAML items.""" |
486 | 488 |
with codecs.open(os.path.join(localdir, 'rss_feed.xml'), 'wb', 'utf-8') as f: |
487 |
- f.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<rss version=\"2.0\">\n<channel>\n<title>Trending at TechCrunch</title><link>http://techcrunch.dlma.com</link>") |
|
489 |
+ f.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n<channel>\n<atom:link href=\"http://techcrunch.dlma.com/rss_feed.xml\" rel=\"self\" type=\"application/rss+xml\"/>\n<title>Trending at TechCrunch</title><link>http://techcrunch.dlma.com</link>") |
|
488 | 490 |
f.write("<pubDate>%s</pubDate><description>Automatically Generated Feed</description><language>en-us</language>\n" % (time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()))) |
489 | 491 |
count = 0 |
490 | 492 |
for item in yaml_items: |
... | ... |
@@ -557,7 +559,7 @@ if __name__=='__main__': |
557 | 559 |
if any_entry_added: |
558 | 560 |
weekend_stats, weekday_stats = analysis.process_feed(items, rhs_metric, rhs_metric_times) |
559 | 561 |
|
560 |
- # We'll only look at the stats for the time 1:00 to 1:30 after posting. |
|
562 |
+ # We'll only look at the stats up to 2 hours after posting. |
|
561 | 563 |
weekend_median, weekend_mean, weekend_sigma = weekend_stats[2] |
562 | 564 |
weekend_threshold = weekend_mean + weekend_sigma |
563 | 565 |
weekday_median, weekday_mean, weekday_sigma = weekday_stats[2] |
... | ... |
@@ -571,10 +573,11 @@ if __name__=='__main__': |
571 | 573 |
if item['qualified'] == -1: |
572 | 574 |
for i in range(len(item[rhs_metric_times])): |
573 | 575 |
r_time = item[rhs_metric_times][i] |
574 |
- if r_time - item['orig_posted'] < 5400: |
|
576 |
+ if r_time - item['orig_posted'] < 7200: |
|
575 | 577 |
if item[rhs_metric][i] >= threshold: |
576 | 578 |
item['qualified'] = threshold |
577 |
- if r_time - item['orig_posted'] >= 3600: |
|
579 |
+ break |
|
580 |
+ else: |
|
578 | 581 |
break |
579 | 582 |
|
580 | 583 |
# Automatically add those items whose authors and tags I like |
581 | 584 |