Update (rss): add domain blacklist

This commit is contained in:
2023-11-23 21:40:53 +08:00
parent 0a1987f593
commit 1f7bfb130e
4 changed files with 58 additions and 18 deletions

View File

@@ -11,6 +11,7 @@ public static function handleMulti($hours = 3)
{
$rss_urls = config('platform.global.rss');
$raw_posts = [];
foreach ($rss_urls as $rss_url) {
@@ -26,6 +27,8 @@ public static function handleMulti($hours = 3)
public static function handleSingle($rss_url, $hours = 3)
{
$blacklist_rss_post_domain = config('platform.global.blacklist_rss_post_domain');
$f = FeedReader::read($rss_url);
@@ -41,6 +44,17 @@ public static function handleSingle($rss_url, $hours = 3)
$title = trim($item->get_title());
$description = trim($item->get_content());
$domain = get_domain_from_url($item->get_link());
if (in_array($domain, $blacklist_rss_post_domain))
{
continue ;
}
$raw_posts[] = (object) [
'source' => $f->get_title(),
'source_url' => $rss_url,

View File

@@ -141,9 +141,23 @@ public static function handle(int $rss_post_id)
$rss_post->keyword_list = implode(',', $words_to_add_in_keyword_list);
if (is_empty($rss_post->bites))
{
$rss_post->status = 'blocked';
}
else
{
$rss_post->status = 'published';
}
if ($rss_post->save()) {
if ($rss_post->status == 'published')
{
$has_saved_keyword = false;
$deleted_rpk = RssPostKeyword::where('rss_post_id', $rss_post->id)->delete();
@@ -169,6 +183,9 @@ public static function handle(int $rss_post_id)
$rss_post->keyword_saved = true;
$rss_post->save();
}
}
}
}

View File

@@ -10,6 +10,13 @@
'https://u.today',
],
'blacklist_rss_post_domain' => [
'www.techinasia.com',
'www.marktechpost.com',
'twitter.com',
'www.youtube.com',
],
'rss' => [
'http://news.ycombinator.com/rss',
// 'http://blog.samaltman.com/posts.atom',

View File

@@ -57,6 +57,8 @@
$last_record = RssPost::whereNull('post_domain')->orderBy('id', 'DESC')->first();
dd($last_record);
for ($i = 1; $i <= $last_record->id; $i++) {
$rss_post = RssPost::find($i);