You are not logged in.

#26 2016-03-23 03:27:58

MountainX
Member
Registered: 2016-02-08
Posts: 371

Re: A simple but well coloured feed reader written in bash

grufo wrote:
skanky wrote:

Right, this worked for me:

Great! smile
This is the script with your suggestions:

#!/bin/bash
if [ ! -n "$FEED_BOOKMARKS" ]; then export FEED_BOOKMARKS=$HOME/.feed_bookmarks; fi
if [ ! -d "$FEED_BOOKMARKS" ]; then mkdir -p $FEED_BOOKMARKS; fi

feed() {
	if [ ! -d $FEED_BOOKMARKS ]; then mkdir $FEED_BOOKMARKS; fi

	if [ ! -n "$1" ]; then
		echo -e "\\n \\e[04mUsage\\e[00m\\n\\n   \\e[01;37m\$ feed \\e[01;31m<url>\\e[00m \\e[01;31m<new bookmark?>\\e[00m\\n\\n \\e[04mSee also\\e[00m\\n\\n   \\e[01;37m\$ deef\\e[00m\\n"
		return 1;
	fi

	local rss_source="$(curl --silent $1 | sed -e ':a;N;$!ba;s/\n/ /g')";

	if [ ! -n "$rss_source" ]; then
		echo "The feed is empty";
		return 1;
	fi

	# THE RSS PARSER
	# The characters "£, §" are used as metacharacters. They should not be encountered in a feed...
	echo -e "$(echo $rss_source | \
		sed -e 's/&amp;/\&/g
		s/&lt;\|&#60;/</g
		s/&gt;\|&#62;/>/g
		s/<\/a>/£/g
		s/href\=\"/§/g
		s/<title>/\\n\\n\\n   :: \\e[01;31m/g; s/<\/title>/\\e[00m ::\\n/g
		s/<link>/ [ \\e[01;36m/g; s/<\/link>/\\e[00m ]/g
		s/<description>/\\n\\n\\e[00;37m/g; s/<\/description>/\\e[00m\\n\\n/g
		s/<p\( [^>]*\)\?>\|<br\s*\/\?>/\n/g
		s/<b\( [^>]*\)\?>\|<strong\( [^>]*\)\?>/\\e[01;30m/g; s/<\/b>\|<\/strong>/\\e[00;37m/g
		s/<i\( [^>]*\)\?>\|<em\( [^>]*\)\?>/\\e[41;37m/g; s/<\/i>\|<\/em>/\\e[00;37m/g
		s/<u\( [^>]*\)\?>/\\e[4;37m/g; s/<\/u>/\\e[00;37m/g
		s/<code\( [^>]*\)\?>/\\e[00m/g; s/<\/code>/\\e[00;37m/g
		s/<a[^§]*§\([^\"]*\)\"[^>]*>\([^£]*\)[^£]*£/\\e[01;31m\2\\e[00;37m \\e[01;34m[\\e[00;37m \\e[04m\1\\e[00;37m\\e[01;34m ]\\e[00;37m/g
		s/<li\( [^>]*\)\?>/\n \\e[01;34m*\\e[00;37m /g
		s/<!\[CDATA\[\|\]\]>//g
		s/\|>\s*<//g
		s/ *<[^>]\+> */ /g
		s/[<>£§]//g')\n\n";
	# END OF THE RSS PARSER

	if [ -n "$2" ]; then
		echo "$1" > $FEED_BOOKMARKS/$2
		echo -e "\\n\\t\\e[01;37m==> \\e[01;31mBookmark saved as \\e[01;36m\\e[04m$2\\e[00m\\e[01;37m <==\\e[00m\\n"
	fi
}

deef() {
	if test -n "$1"; then
		if [ ! -r "$FEED_BOOKMARKS/$1" ]; then
			echo -e "\\n \\e[01;31mBookmark \\e[01;36m\\e[04m$1\\e[00m\\e[01;31m not found.\\e[00m\\n\\n \\e[04mType:\\e[00m\\n\\n   \\e[01;37m\$ deef\\e[00m (without arguments)\\n\\n to get the complete list of all currently saved bookmarks.\\n";
			return 1;
		fi
		local url="$(cat $FEED_BOOKMARKS/$1)";
		if [ ! -n "$url" ]; then
			echo "The bookmark is empty";
			return 1;
		fi
		echo -e "\\n\\t\\e[01;37m==> \\e[01;31m$url\\e[01;37m <==\\e[00m"
		feed "$url";
	else
		echo -e "\\n \\e[04mUsage\\e[00m\\n\\n   \\e[01;37m\$ deef \\e[01;31m<bookmark>\\e[00m\\n\\n \\e[04mCurrently saved bookmarks\\e[00m\\n";
		for i in $(find $FEED_BOOKMARKS -maxdepth 1 -type f);
			do echo -e "   \\e[01;36m\\e[04m$(basename $i)\\e[00m";
		done;
		echo -e "\\n \\e[04mSee also\\e[00m\\n\\n   \\e[01;37m\$ feed\\e[00m\\n";
	fi;
}

Any idea about this error?

deef archnews
        ==> http://www.archlinux.org/feeds/news/ <==
sed: -e expression #1, char 772: unterminated `s' command

Offline

#27 2016-03-23 10:02:32

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: A simple but well coloured feed reader written in bash

Something is messing up the sed instruction so that it doesn't find the end /  (nor the g if there is one). This could be down to a ' in an embedded variable?
Is that code the actual code, or has it been changed?


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#28 2016-03-23 19:50:17

MountainX
Member
Registered: 2016-02-08
Posts: 371

Re: A simple but well coloured feed reader written in bash

skanky wrote:

Something is messing up the sed instruction so that it doesn't find the end /  (nor the g if there is one). This could be down to a ' in an embedded variable?
Is that code the actual code, or has it been changed?

I copied and pasted directly from the post above (the post I quoted). I did not change anything. When I got the error, I copied and pasted again. Same error. Then I went to one of the other posts in this thread that has a modified version of the script. It gave me the same error, but at a different line number.

Nobody else is getting the error?

I'm running the script in bash on Arch with all packages up to date.

Offline

#29 2016-03-23 20:18:57

loh.tar
Member
Registered: 2010-10-17
Posts: 49

Re: A simple but well coloured feed reader written in bash

Nobody else is getting the error?

I copy & paste from your post #26 and got not your error. But the hint that the news are moved to https

Offline

#30 2016-03-23 20:36:15

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: A simple but well coloured feed reader written in bash

MountainX wrote:
skanky wrote:

Something is messing up the sed instruction so that it doesn't find the end /  (nor the g if there is one). This could be down to a ' in an embedded variable?
Is that code the actual code, or has it been changed?

I copied and pasted directly from the post above (the post I quoted). I did not change anything. When I got the error, I copied and pasted again. Same error. Then I went to one of the other posts in this thread that has a modified version of the script. It gave me the same error, but at a different line number.

Nobody else is getting the error?

I'm running the script in bash on Arch with all packages up to date.

It may be something that your browser/editor is doing with the copied text? Can you manually check the code in the sed call and/or look for non-displaying chars. I haven't tried running this code in ages (been meaning to switch back to give it a try), but when I did I didn't get the error.


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#31 2016-03-23 22:32:27

MountainX
Member
Registered: 2016-02-08
Posts: 371

Re: A simple but well coloured feed reader written in bash

skanky wrote:
MountainX wrote:
skanky wrote:

Something is messing up the sed instruction so that it doesn't find the end /  (nor the g if there is one). This could be down to a ' in an embedded variable?
Is that code the actual code, or has it been changed?

I copied and pasted directly from the post above (the post I quoted). I did not change anything. When I got the error, I copied and pasted again. Same error. Then I went to one of the other posts in this thread that has a modified version of the script. It gave me the same error, but at a different line number.

Nobody else is getting the error?

I'm running the script in bash on Arch with all packages up to date.

It may be something that your browser/editor is doing with the copied text? Can you manually check the code in the sed call and/or look for non-displaying chars. I haven't tried running this code in ages (been meaning to switch back to give it a try), but when I did I didn't get the error.

I've been doing my best to figure out the problem but so far I am still getting the error. I'm reading this forum with Firefox and I'm using kate and/or nano to edit (tried both). All I'm doing is copy/paste. My pasted code looks exactly like what I'm reading on the forum. I don't see any obvious copy/paste errors.

Offline

#32 2016-03-24 10:59:49

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: A simple but well coloured feed reader written in bash

I've just tried it, and it works fine for me. Sorry, I can't think of any other possibility than something's messing with the characters. hmm


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#33 2017-05-26 10:33:57

glyons
Member
From: Europa
Registered: 2016-10-14
Posts: 37

Re: A simple but well coloured feed reader written in bash

Hi

..........snip............

EDIT
Nevermind , I figured  out problem myself in the meantime ,  Cannot delete post.

Last edited by glyons (2017-05-27 17:18:30)

Offline

Board footer

Powered by FluxBB