[lifepress] better filtering of twitter?

1 view
Skip to first unread message

!!blue

unread,
May 12, 2010, 5:24:56 PM5/12/10
to Lifepress
I'm trying to filter out twitter entries with certain links and those
that are @ replies.

This block of code in the twitter plugin is not working in the pre_db
part:

<code>
//filter out @replies (set as unpublished)
if (substr($item->item_title, 0, 1) == '@') {
$item->item_status = 'draft';
}
if (stripos($item->item_title, 'http://blip.fm/') > 0) {
$item->item_status = 'draft';
}
if (stripos($item->item_title, 'http://twitpic.com/') > 0) {
$item->item_status = 'draft';
}
if (stripos($item->item_title, 'http://ff.im/') > 0) {
$item->item_status = 'draft';
}
if (stripos($item->item_title, 'http://tumblr.com/') > 0) {
$item->item_status = 'draft';
}
</code>

The code is from this thread:
http://groups.google.com/group/sweetcron/browse_thread/thread/66f9dae87db51f7b/3b40f0219eb13629

It doesn't seem to be drafting the tweets @ replies at all, and the
other filters are randomly working. What am I doing wrong? Or does the
plugin only work on new posts instead of going back and applying
changes to all db entries?


Mitchell McKenna

unread,
May 12, 2010, 6:28:52 PM5/12/10
to Lifepress
Are the following lines in your twitter plugin to remove the username
from the title?
$twitter_username = explode('/', $original_publisher);
$twitter_username = $twitter_username[3];

//remove username from front of posts
$item->item_title = trim(str_replace($twitter_username.':', '',
$item->item_title));

There's likely a problem with how the title's being stored, echo out
the title in the pre_display function eg. add the following line to
pre_display() fuction...
var_dump($item->item_title)
So you can see if the @ sign really is the first character in the
item_title string.

On May 12, 2:24 pm, "!!blue" <zob...@gmail.com> wrote:
> I'm trying to filter out twitter entries with certain links and those
> that are @ replies.
>
> This block of code in the twitter plugin is not working in the pre_db
> part:
>
> <code>
> //filter out @replies (set as unpublished)
> if (substr($item->item_title, 0, 1) == '@') {
>         $item->item_status = 'draft';}
>
> if (stripos($item->item_title, 'http://blip.fm/') > 0) {
>         $item->item_status = 'draft';}
>
> if (stripos($item->item_title, 'http://twitpic.com/') > 0) {
>         $item->item_status = 'draft';}
>
> if (stripos($item->item_title, 'http://ff.im/') > 0) {
>         $item->item_status = 'draft';}
>
> if (stripos($item->item_title, 'http://tumblr.com/') > 0) {
>         $item->item_status = 'draft';}
>
> </code>
>
> The code is from this thread:http://groups.google.com/group/sweetcron/browse_thread/thread/66f9dae...

!!blue

unread,
May 13, 2010, 1:50:50 PM5/13/10
to Lifepress

On May 12, 5:28 pm, Mitchell McKenna <mitchellmcke...@gmail.com>
wrote:
> Are the following lines in your twitter plugin to remove the username
> from the title?
> $twitter_username = explode('/', $original_publisher);
>                 $twitter_username = $twitter_username[3];
>
>                 //remove username from front of posts
>                 $item->item_title = trim(str_replace($twitter_username.':', '',
> $item->item_title));

Yeah, there's code the remove the first instance of the @ username
however mine is a bit different:
<code>
//remove username from front of posts
$item->item_title = preg_replace("#^\S+#", '', $item->item_title);
</code>

I seem to be using an old version of the plugin! I'll check the
Lifepress source code for the latest ;p

> There's likely a problem with how the title's being stored, echo out
> the title in the pre_display function eg. add the following line to
> pre_display() fuction...
> var_dump($item->item_title)
> So you can see if the @ sign really is the first character in the
> item_title string.

I think you're right, I'm going to read up on these different PHP
functions (str_replace, preg_replace) too and see what a mess I make
of everything. Ha!

!!blue

unread,
May 13, 2010, 4:32:45 PM5/13/10
to Lifepress


On May 13, 12:50 pm, "!!blue" <zob...@gmail.com> wrote:
> On May 12, 5:28 pm, Mitchell McKenna <mitchellmcke...@gmail.com>
> wrote:
>
> I seem to be using an old version of the plugin! I'll check the
> Lifepress source code for the latest ;p
>

It's working now, I matched the code to the current lifepress plugin
code. I only wish the code could also apply to past entries. :p I'm
not comfortable editing the DB by hand. :p
Reply all
Reply to author
Forward
0 new messages