tweeper.git
6 years agotweeper.php: use the same parenthesis style for all functions
Antonio Ospite [Mon, 16 May 2016 13:35:58 +0000 (15:35 +0200)]
tweeper.php: use the same parenthesis style for all functions

6 years agotweeper: fix style issues found by Coder Sniffer
Antonio Ospite [Mon, 16 May 2016 13:34:20 +0000 (15:34 +0200)]
tweeper: fix style issues found by Coder Sniffer

----------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
 1 | ERROR | [x] Missing file doc comment
 4 | ERROR | [x] "require" is a statement not a function; no
   |       |     parentheses are required
 4 | ERROR | [x] Language constructs must be followed by a single
   |       |     space; expected "require (" but found "require("

6 years agotweeper.php: rename $rootName to $root_node_name
Antonio Ospite [Mon, 16 May 2016 11:12:22 +0000 (13:12 +0200)]
tweeper.php: rename $rootName to $root_node_name

6 years agotweeper.php: make json_to_xml() do strictly what its name says
Antonio Ospite [Mon, 16 May 2016 11:10:28 +0000 (13:10 +0200)]
tweeper.php: make json_to_xml() do strictly what its name says

Extracting the json data from the HTML does not really belong to the
json_to_xml() function.

6 years agoUse https in URLs for Twitter.com and ao2.it
Antonio Ospite [Sun, 15 May 2016 14:48:28 +0000 (16:48 +0200)]
Use https in URLs for Twitter.com and ao2.it

6 years agorss_converter_twitter.com.xsl: fix getting the profile picture URL
Antonio Ospite [Sun, 15 May 2016 14:13:58 +0000 (16:13 +0200)]
rss_converter_twitter.com.xsl: fix getting the profile picture URL

6 years agorss_converter_dilbert.com.xsl: put the full text in the alt attribute
Antonio Ospite [Sun, 15 May 2016 14:12:12 +0000 (16:12 +0200)]
rss_converter_dilbert.com.xsl: put the full text in the alt attribute

6 years agorss_converter_dilbert.com.xsl: ellipsize long titles
Antonio Ospite [Sun, 15 May 2016 14:03:29 +0000 (16:03 +0200)]
rss_converter_dilbert.com.xsl: ellipsize long titles

6 years agorss_converter_facebook.com.xsl: fix getting the item description
Antonio Ospite [Sun, 15 May 2016 13:52:10 +0000 (15:52 +0200)]
rss_converter_facebook.com.xsl: fix getting the item description

Hopefully this is a more stable way to get just the useful content of
a story skipping the header and the footer.

6 years agorss_converter_facebook.com.xsl: fix the permalink
Antonio Ospite [Sun, 15 May 2016 13:34:13 +0000 (15:34 +0200)]
rss_converter_facebook.com.xsl: fix the permalink

Use the page id and the story id to build a more robust permalink URL.

6 years agoNEWS: add release notes for the v0.5 release v0.5
Antonio Ospite [Fri, 13 May 2016 16:12:56 +0000 (18:12 +0200)]
NEWS: add release notes for the v0.5 release

6 years agoINSTALL: mention php-symfony-serializer instead of php-xml-serializer
Antonio Ospite [Fri, 13 May 2016 16:09:13 +0000 (18:09 +0200)]
INSTALL: mention php-symfony-serializer instead of php-xml-serializer

6 years agoUse the Symfony Serializer component instead of the PEAR XML_Serializer
Antonio Ospite [Fri, 13 May 2016 16:00:04 +0000 (18:00 +0200)]
Use the Symfony Serializer component instead of the PEAR XML_Serializer

XML_Serializer is old and unmaintained, and it is going to be removed
from Debian, so use a more robust and supported alternative.

6 years agorss_converter_twitter.com.xsl: restrict tweet selection some more
Antonio Ospite [Mon, 30 Nov 2015 10:22:27 +0000 (11:22 +0100)]
rss_converter_twitter.com.xsl: restrict tweet selection some more

Only select elements which have the 'data-item-id' attribute, this way
we avoid picking up the image gallery at the top of hashtag pages which
does not have an RSS item structure.

JFTR the gallery is inside an element like this:

  <li class="AdaptiveStreamImageGallery AdaptiveSearchTimeline-separationModule js-stream-item"
      data-item-type="tweet">

with no 'data-item-id'.

6 years agorss_converter_twitter.com.xsl: set a fall-back channel title
Antonio Ospite [Fri, 27 Nov 2015 12:46:55 +0000 (13:46 +0100)]
rss_converter_twitter.com.xsl: set a fall-back channel title

When there is no screen-name, like for hashtag ans searches pages, use
the main page title as the RSS channel title.

6 years agorss_converter_twitter.com.xsl: restrict the criterion to match actual tweets
Antonio Ospite [Fri, 27 Nov 2015 11:47:50 +0000 (12:47 +0100)]
rss_converter_twitter.com.xsl: restrict the criterion to match actual tweets

By only using li[@data-item-type='tweet'] sometimes void entries where
selected, and in particular the ones under <ol class="activity-popup-users">.

So just pick the items under <ol id="stream-items-id"> as the actual tweets
with valid contents in them.

6 years agoNEWS: add release notes for the v0.4 release v0.4
Antonio Ospite [Sun, 13 Sep 2015 18:05:53 +0000 (20:05 +0200)]
NEWS: add release notes for the v0.4 release

6 years agorss_converter_instagram.com.xsl: use the username when there is no full name
Antonio Ospite [Sun, 13 Sep 2015 16:43:31 +0000 (18:43 +0200)]
rss_converter_instagram.com.xsl: use the username when there is no full name

6 years agorss_converter_instagram.com.xsl: improve channel description
Antonio Ospite [Sun, 13 Sep 2015 16:06:59 +0000 (18:06 +0200)]
rss_converter_instagram.com.xsl: improve channel description

Some users have a biography, some users only have an external URL, some
users have both and some have neither.

Make the channel description a little smarter trying to handle these
case.

6 years agorss_converter_facebook.com.xsl: fix channel title, link and description
Antonio Ospite [Sun, 13 Sep 2015 15:43:13 +0000 (17:43 +0200)]
rss_converter_facebook.com.xsl: fix channel title, link and description

It looks like using the meta elements does not work anymore.

6 years agoTODO: support for images on Twitter.com can be improved
Antonio Ospite [Sun, 13 Sep 2015 09:59:43 +0000 (11:59 +0200)]
TODO: support for images on Twitter.com can be improved

6 years agotweeper.1.asciidoc: update the copyright years
Antonio Ospite [Sun, 13 Sep 2015 09:59:15 +0000 (11:59 +0200)]
tweeper.1.asciidoc: update the copyright years

6 years agotweeper.1.asciidoc: document how to use the PHP built-in web server
Antonio Ospite [Sun, 13 Sep 2015 09:57:07 +0000 (11:57 +0200)]
tweeper.1.asciidoc: document how to use the PHP built-in web server

6 years agoREADME: improve wording in a paragraph
Antonio Ospite [Sun, 13 Sep 2015 09:55:59 +0000 (11:55 +0200)]
README: improve wording in a paragraph

6 years agotweeper.1.asciidoc: describe what tweeper is in a more generic way
Antonio Ospite [Sun, 13 Sep 2015 09:52:51 +0000 (11:52 +0200)]
tweeper.1.asciidoc: describe what tweeper is in a more generic way

6 years agoREADME: describe what tweeper is in a more generic way
Antonio Ospite [Sun, 13 Sep 2015 09:41:35 +0000 (11:41 +0200)]
README: describe what tweeper is in a more generic way

Since tweeper does not support only Twitter.com but also other social
websites, give a more general idea of what it can be used for.

7 years agorss_converter_instagram.com.xsl: show the user name in the titles
Antonio Ospite [Wed, 29 Jul 2015 21:05:47 +0000 (23:05 +0200)]
rss_converter_instagram.com.xsl: show the user name in the titles

This makes it easier to see who created the item when different
Instagram feeds are grouped into a directory.

7 years agotweeper: avoid a reference to $argv in non-cli mode
Antonio Ospite [Wed, 29 Jul 2015 20:56:42 +0000 (22:56 +0200)]
tweeper: avoid a reference to $argv in non-cli mode

$argv is not defined in non-cli mode, so protect its usage behind an
is_cli() check.

For instance, this avoids a message in the PHP built-in web server, when
usage() gets called:

  PHP Notice:  Undefined variable: argv in .../tweeper.php on line 357

7 years agotweeper: make is_cli() stricter
Antonio Ospite [Wed, 29 Jul 2015 20:52:15 +0000 (22:52 +0200)]
tweeper: make is_cli() stricter

Assume that tweeper is running from an actual command line only when
php_sapi_name() matches _exactly_ the string "cli".

This makes it possible to use tweeper in a browser using the PHP
built-in web server, for which php_sapi_name() returns "cli-server".

7 years agoTODO: remove item about duplicated RSS items
Antonio Ospite [Sat, 25 Jul 2015 13:52:57 +0000 (15:52 +0200)]
TODO: remove item about duplicated RSS items

Now all the generated feeds use the <guid/> element to uniquely identify
items.

7 years agoTODO: remove item about Instagram videos
Antonio Ospite [Sat, 25 Jul 2015 13:50:12 +0000 (15:50 +0200)]
TODO: remove item about Instagram videos

Even if tweeper does not show the video itself in the RSS item content
it at least tells the user that the content is a video, so consider this
done.

7 years agorss_converter_instagram.com.xsl: add a label if the content is a video
Antonio Ospite [Sat, 25 Jul 2015 13:45:33 +0000 (15:45 +0200)]
rss_converter_instagram.com.xsl: add a label if the content is a video

7 years agorss_converter_instagram.com.xsl: fix enclosure generation
Antonio Ospite [Sat, 25 Jul 2015 11:08:31 +0000 (13:08 +0200)]
rss_converter_instagram.com.xsl: fix enclosure generation

7 years agorss_converter_instagram.com.xsl: ellipsize titles
Antonio Ospite [Sat, 25 Jul 2015 10:48:30 +0000 (12:48 +0200)]
rss_converter_instagram.com.xsl: ellipsize titles

7 years agorss_converter_instagram.com.xsl: use the image caption as the item content
Antonio Ospite [Sat, 25 Jul 2015 10:43:49 +0000 (12:43 +0200)]
rss_converter_instagram.com.xsl: use the image caption as the item content

Instagram has reintroduced serving the image caption in the json data,
so use it; it is way nicer than the stats tweeper was showing before.

7 years agorss_converter_instagram.com.xsl: use better name for the image variable
Antonio Ospite [Sat, 25 Jul 2015 10:36:58 +0000 (12:36 +0200)]
rss_converter_instagram.com.xsl: use better name for the image variable

7 years agoAdd support for Facebook.com public pages
Antonio Ospite [Wed, 1 Jul 2015 11:47:53 +0000 (13:47 +0200)]
Add support for Facebook.com public pages

7 years agotweeper.php: support host-specific methods for preprocessing the HTML data
Antonio Ospite [Wed, 1 Jul 2015 11:37:57 +0000 (13:37 +0200)]
tweeper.php: support host-specific methods for preprocessing the HTML data

Some sites serve mangled HTML code, so a mechanism to clean it up before
loading it as XML is needed.

For instance, facebook.com puts come content inside HTML comments, and
these must be stripped in order to make the content available to the
HTML parser when loading the data into a DOMDocument.

7 years agotweeper.php: strip the leading "www." from hosts
Antonio Ospite [Wed, 1 Jul 2015 11:35:56 +0000 (13:35 +0200)]
tweeper.php: strip the leading "www." from hosts

This makes tweeper more forgiving when it is passed URLs either with or
without the "www" subdomain for the same host.

7 years agotweeper.php: make error about missing stylesheet more explicit
Antonio Ospite [Wed, 1 Jul 2015 11:34:53 +0000 (13:34 +0200)]
tweeper.php: make error about missing stylesheet more explicit

7 years agorss_converter_instagram.com.xsl: update to new json format
Antonio Ospite [Fri, 12 Jun 2015 10:06:02 +0000 (12:06 +0200)]
rss_converter_instagram.com.xsl: update to new json format

The new Instagram homepage provides json data in a format different than
before, update the xsl to support it.

Unfortunately the data in the new format does not provide the
descriptions of the items, so use some placeholder values (URL, comments
count, likes count) to present at least something.

7 years agorss_converter_twitter.com.xsl: update XPath of tweet content
Antonio Ospite [Sun, 31 May 2015 17:17:28 +0000 (19:17 +0200)]
rss_converter_twitter.com.xsl: update XPath of tweet content

Using the role attribute to differentiate between original tweets and
quoted tweet, as introduced in commit 4c2e986, does not work anymore,
but the fact that original tweets are <li></li> elements while quoted
tweets are <div></div> elements can be used instead.

7 years agorss_converter_twitter.com.xsl: improve matching the permalink
Antonio Ospite [Tue, 5 May 2015 07:28:23 +0000 (09:28 +0200)]
rss_converter_twitter.com.xsl: improve matching the permalink

Extract the permalink using the @data-permalink-path attribute, this
works for withheld tweets too preventing them from having all the same
guid.

7 years agorss_converter_twitter.com.xsl: restrict tweet matching
Antonio Ospite [Tue, 5 May 2015 07:25:20 +0000 (09:25 +0200)]
rss_converter_twitter.com.xsl: restrict tweet matching

With new style retweets the quoted text is also matched by
[@data-item-type='tweet'] but then the content is not handled, resulting
in empty items in the RSS feed.

Checking also for @role='listitem' allows to pick up only top-level
tweets.

7 years agotweeper.php: make date handling functions a little more robust
Antonio Ospite [Tue, 5 May 2015 07:21:48 +0000 (09:21 +0200)]
tweeper.php: make date handling functions a little more robust

Provide at least _some_ error checking and a fall-back value for invalid
dates.

7 years agotweeper.php: factor out an is_cli() function
Antonio Ospite [Mon, 2 Mar 2015 14:05:54 +0000 (15:05 +0100)]
tweeper.php: factor out an is_cli() function

7 years agoREADME: mention the supported sites in the README file
Antonio Ospite [Mon, 2 Mar 2015 12:05:32 +0000 (13:05 +0100)]
README: mention the supported sites in the README file

7 years agotweeper.1.asciidoc: mention the supported sites in the man page
Antonio Ospite [Mon, 2 Mar 2015 12:00:59 +0000 (13:00 +0100)]
tweeper.1.asciidoc: mention the supported sites in the man page

7 years agoTODO: update some entries
Antonio Ospite [Mon, 2 Mar 2015 11:59:12 +0000 (12:59 +0100)]
TODO: update some entries

The new Dilbert.com site does not have a different /fast version, so no
point in mentioning it.

Mention possible support for Instagram videos.

7 years agoAdd support for converting Instagram user timelines to RSS
Antonio Ospite [Sat, 28 Feb 2015 00:54:34 +0000 (01:54 +0100)]
Add support for converting Instagram user timelines to RSS

7 years agotweeper.php: add infrastructure for sites using json data
Antonio Ospite [Sat, 28 Feb 2015 00:50:21 +0000 (01:50 +0100)]
tweeper.php: add infrastructure for sites using json data

Some websites provide the timelines as json data and convert that to
html in the client.

Supporting these sites will be done by defining host specific methods to
extract the json data to pass to json_to_xml().

7 years agotweeper.php: fix validation when generating enclosure elements
Antonio Ospite [Sat, 28 Feb 2015 00:43:41 +0000 (01:43 +0100)]
tweeper.php: fix validation when generating enclosure elements

The RSS specification says that the enclosure element url must be http.
See http://sourceforge.net/p/feedvalidator/bugs/72/

So follow the specification, for now. If feedvalidator decides to relax
this requirement this hack will be removed.

7 years agotweeper.php: factor out an html_to_xml() function from the tweep() method
Antonio Ospite [Fri, 27 Feb 2015 16:08:31 +0000 (17:08 +0100)]
tweeper.php: factor out an html_to_xml() function from the tweep() method

Split the operation to get some xml out of the web page, this in
preparation for adding some more flexibility about what can be converted
to xml for a subsequent transformation.

7 years agotweeper.php: move loading the stylesheet into the Tweeper class
Antonio Ospite [Fri, 27 Feb 2015 15:54:57 +0000 (16:54 +0100)]
tweeper.php: move loading the stylesheet into the Tweeper class

Let the Tweeper class load the stylesheet, specifically when the tweep()
method is called.

This way the same Tweeper object can be reused to convert different URLs
from different websites.

7 years agorss_converter_twitter.com.xsl: use ProfileHeaderCard as channel description
Antonio Ospite [Fri, 27 Feb 2015 15:47:44 +0000 (16:47 +0100)]
rss_converter_twitter.com.xsl: use ProfileHeaderCard as channel description

7 years agoStrip trailing newlines
Antonio Ospite [Fri, 27 Feb 2015 14:16:55 +0000 (15:16 +0100)]
Strip trailing newlines

7 years agorss_converter_pump.io.xsl: make the feed validate with feedvalidator.org
Antonio Ospite [Fri, 27 Feb 2015 14:05:13 +0000 (15:05 +0100)]
rss_converter_pump.io.xsl: make the feed validate with feedvalidator.org

Make the pump.io feed validate with http://feedvalidator.org and also
improve compatibility by providing a guid and by excluding the weird
xmlns:php namespace in the output.

7 years agorss_converter_dilbert.com.xsl: make the feed validate with feedvalidator.org
Antonio Ospite [Fri, 27 Feb 2015 12:59:38 +0000 (13:59 +0100)]
rss_converter_dilbert.com.xsl: make the feed validate with feedvalidator.org

Make the Dilbert.com feed validate with http://feedvalidator.org and also
improve compatibility by providing a guid and by excluding the weird
xmlns:php namespace in the output.

7 years agorss_converter_dilbert.com.xsl: fixes for the new dilbert.com
Antonio Ospite [Fri, 27 Feb 2015 12:58:33 +0000 (13:58 +0100)]
rss_converter_dilbert.com.xsl: fixes for the new dilbert.com

Make the stylesheet work again with the new dilbert.com website.

7 years agorss_converter_howtoons.com.xsl: make the feed validate with feedvalidator.org
Antonio Ospite [Fri, 27 Feb 2015 12:29:32 +0000 (13:29 +0100)]
rss_converter_howtoons.com.xsl: make the feed validate with feedvalidator.org

Make the Howtoons.com feed validate with http://feedvalidator.org and
also improve compatibility by providing a guid and by excluding the
weird xmlns:php namespace in the output.

7 years agorss_converter_twitter.com.xsl: improve the naming of some variables
Antonio Ospite [Fri, 27 Feb 2015 12:24:25 +0000 (13:24 +0100)]
rss_converter_twitter.com.xsl: improve the naming of some variables

Use item-content and item-permalink instead of tweet-text and
tweet-link, this way other stylesheets can use the same names resulting
in more consistency.

7 years agorss_converter_twitter.com.xsl: rename twitterBaseURL to BaseURL
Antonio Ospite [Fri, 27 Feb 2015 12:15:59 +0000 (13:15 +0100)]
rss_converter_twitter.com.xsl: rename twitterBaseURL to BaseURL

This way the same notation is used in all the stylesheets.

7 years agorss_converter_twitter.com.xsl: make the feed validate with feedvalidator.org
Antonio Ospite [Fri, 27 Feb 2015 12:10:20 +0000 (13:10 +0100)]
rss_converter_twitter.com.xsl: make the feed validate with feedvalidator.org

Make the Twitter feed validate with http://feedvalidator.org and also
improve compatibility by providing a guid and by excluding the weird
xmlns:php namespace in the output.

8 years agoNEWS: add release notes for the v0.3 release v0.3
Antonio Ospite [Thu, 24 Apr 2014 12:29:40 +0000 (14:29 +0200)]
NEWS: add release notes for the v0.3 release

8 years agoUpdate email address and copyright years
Antonio Ospite [Thu, 24 Apr 2014 11:50:33 +0000 (13:50 +0200)]
Update email address and copyright years

8 years agoAdd a stylesheet for Howtoons.com
Antonio Ospite [Thu, 24 Apr 2014 11:46:33 +0000 (13:46 +0200)]
Add a stylesheet for Howtoons.com

8 years agorss_converter_twitter.com.xsl: fix getting the profile picture
Antonio Ospite [Thu, 24 Apr 2014 10:02:17 +0000 (12:02 +0200)]
rss_converter_twitter.com.xsl: fix getting the profile picture

Some more values are added tot he class attribute so the old equality
check does not work anymore.

Use a contains() check, this is more future proof and allows also to
support both the classic and the new profile pages.

8 years agorss_converter_twitter.com.xsl: support the new Twitter profile page
Antonio Ospite [Thu, 24 Apr 2014 09:58:51 +0000 (11:58 +0200)]
rss_converter_twitter.com.xsl: support the new Twitter profile page

Adjust the XPath expressions to support both the classic and the new
profile pages.

8 years agorss_converter_*.xsl: specify xml:base
Antonio Ospite [Sat, 22 Feb 2014 08:52:38 +0000 (09:52 +0100)]
rss_converter_*.xsl: specify xml:base

Some feed readers expand relative URLs in items by extracting the base
URL from the enclosing <link/> element, however this is not a globally
accepted practice.

Specifying xml:base is useful to cover other ways in which relative URLs
are expanded, see:
  https://cyber.law.harvard.edu/rss/relativeURI.html
  http://www.w3.org/TR/xmlbase/#resolution

8 years agotweeper.php: support generating enclosure for "audio/ogg"
Antonio Ospite [Fri, 27 Dec 2013 08:32:25 +0000 (09:32 +0100)]
tweeper.php: support generating enclosure for "audio/ogg"

8 years agotweeper.1.asciidoc: reword some list items
Antonio Ospite [Wed, 20 Nov 2013 00:12:59 +0000 (01:12 +0100)]
tweeper.1.asciidoc: reword some list items

Remove the unneeded "as", it is in the list preamble already.

8 years agoRemove the auto-generated ChangeLog
Antonio Ospite [Tue, 19 Nov 2013 21:30:03 +0000 (22:30 +0100)]
Remove the auto-generated ChangeLog

It is not that useful once we have a nice NEWS file; and the latter can
even be used as upstream changelog in packages.

8 years agotweeper.1.asciidoc: mention a way to use tweeper from a web server
Antonio Ospite [Mon, 18 Nov 2013 22:16:54 +0000 (23:16 +0100)]
tweeper.1.asciidoc: mention a way to use tweeper from a web server

8 years agoMakefile: fix typo s/INTALLATION/INSTALLATION/
Antonio Ospite [Mon, 18 Nov 2013 16:58:14 +0000 (17:58 +0100)]
Makefile: fix typo s/INTALLATION/INSTALLATION/

Thanks-to: gregor herrmann <gregoa@debian.org>

8 years agoChangelog, NEWS: prepare for the v0.2 release v0.2
Antonio Ospite [Mon, 18 Nov 2013 12:20:02 +0000 (13:20 +0100)]
Changelog, NEWS: prepare for the v0.2 release

8 years agotweeper.1.asciidoc: small fixes to the man page
Antonio Ospite [Mon, 18 Nov 2013 11:56:52 +0000 (12:56 +0100)]
tweeper.1.asciidoc: small fixes to the man page

8 years agotweeper.1.asciidoc: add a missing semicolon
Antonio Ospite [Mon, 18 Nov 2013 11:12:16 +0000 (12:12 +0100)]
tweeper.1.asciidoc: add a missing semicolon

8 years agoAdd a ChangeLog file v0.1
Antonio Ospite [Mon, 18 Nov 2013 00:01:29 +0000 (01:01 +0100)]
Add a ChangeLog file

8 years agoAdd a NEWS file
Antonio Ospite [Sun, 17 Nov 2013 23:59:58 +0000 (00:59 +0100)]
Add a NEWS file

8 years agoAdd a Makefile rule to generate a Changelog file
Antonio Ospite [Sun, 17 Nov 2013 23:59:20 +0000 (00:59 +0100)]
Add a Makefile rule to generate a Changelog file

8 years agoAdd a man page
Antonio Ospite [Sun, 17 Nov 2013 23:43:00 +0000 (00:43 +0100)]
Add a man page

8 years agoAdd a Makefile to simplify installation and packaging
Antonio Ospite [Fri, 8 Nov 2013 15:22:26 +0000 (16:22 +0100)]
Add a Makefile to simplify installation and packaging

8 years agoAdd a wrapper script intended to be called as an executable
Antonio Ospite [Fri, 8 Nov 2013 15:17:48 +0000 (16:17 +0100)]
Add a wrapper script intended to be called as an executable

Add also an INSTALL file which explains how to set up tweeper globally
on the filesystem.

8 years agoWrite error messages on STDERR and return saner values in CLI mode
Antonio Ospite [Fri, 8 Nov 2013 14:01:25 +0000 (15:01 +0100)]
Write error messages on STDERR and return saner values in CLI mode

The previous use of die() was not very useful in CLI mode as the script
was always returning 0.

Fix that and also write error messages to the appropriate output stream.

Note the use of 'php://output' as error stream for non CLI mode, this
ensures that error messages would be readable in the browser window.

8 years agoTODO: add more info about checking UTF output
Antonio Ospite [Fri, 8 Nov 2013 12:09:19 +0000 (13:09 +0100)]
TODO: add more info about checking UTF output

8 years agoHandle errors and warnings from loadHTML()
Antonio Ospite [Fri, 8 Nov 2013 09:44:44 +0000 (10:44 +0100)]
Handle errors and warnings from loadHTML()

When parsing invalid documents loadHTML() spits out warnings and errors
which may end up polluting the output of tweeper depending on the value
of the "display_errors" variable in the PHP configuration; this may
result in the output being invalid RSS.

Handling those messages explicitly makes tweeper more robust against
different PHP configurations.

Thanks-to: gregor herrmann <gregoa@debian.org>

8 years agoShow the actual name of the user the tweet comes from
Antonio Ospite [Sun, 6 Oct 2013 09:01:46 +0000 (11:01 +0200)]
Show the actual name of the user the tweet comes from

The old way of using just the screen name made re-tweeted messages look
like they were coming from the re-twitting user instead of the original
author. This is wrong and causes confusion, fix it.

9 years agoFollow HTTP redirects in get_contents() too
Antonio Ospite [Mon, 12 Aug 2013 08:16:27 +0000 (10:16 +0200)]
Follow HTTP redirects in get_contents() too

This is especially needed when http:// URLs are redirected to https://

9 years agoAdd some entries to the TODO file
Antonio Ospite [Sun, 11 Aug 2013 23:25:56 +0000 (01:25 +0200)]
Add some entries to the TODO file

9 years agoMerge branch 'generate-enclosure-element'
Antonio Ospite [Sun, 11 Aug 2013 23:22:35 +0000 (01:22 +0200)]
Merge branch 'generate-enclosure-element'

9 years agoCosmetics: re-indent cURL options to follow the coding style
Antonio Ospite [Sun, 11 Aug 2013 23:16:10 +0000 (01:16 +0200)]
Cosmetics: re-indent cURL options to follow the coding style

9 years agoUse cURL for Tweeper::get_contents() too
Antonio Ospite [Sun, 11 Aug 2013 23:13:56 +0000 (01:13 +0200)]
Use cURL for Tweeper::get_contents() too

So that the same mechanism is used for getting content and info.

Note, the "file://" scheme has to be prepended to local files so cURL
can handle them.

9 years agoRemove double semicolon in Tweeper::get_info()
Antonio Ospite [Sun, 11 Aug 2013 23:06:23 +0000 (01:06 +0200)]
Remove double semicolon in Tweeper::get_info()

9 years agoMake get_url_info() and generate_enclosure() static methods
Antonio Ospite [Sun, 11 Aug 2013 19:23:42 +0000 (21:23 +0200)]
Make get_url_info() and generate_enclosure() static methods

Also rename get_url_info() to get_info() to match the naming scheme of
get_contents().

9 years agoTurn epoch_to_gmdate() and str_to_gmdate() into static methods
Antonio Ospite [Sun, 11 Aug 2013 19:15:41 +0000 (21:15 +0200)]
Turn epoch_to_gmdate() and str_to_gmdate() into static methods

9 years agoMake get_contents() a static method
Antonio Ospite [Sun, 11 Aug 2013 19:11:03 +0000 (21:11 +0200)]
Make get_contents() a static method

9 years agoCosmetics: sort supported_content_types, remove unneeded spaces
Antonio Ospite [Sun, 11 Aug 2013 18:57:02 +0000 (20:57 +0200)]
Cosmetics: sort supported_content_types, remove unneeded spaces

9 years agoUse an array to list supported content types for enclosures
Antonio Ospite [Sun, 11 Aug 2013 18:52:47 +0000 (20:52 +0200)]
Use an array to list supported content types for enclosures

9 years agoMake it optional to generate the <enclosure/> element
Antonio Ospite [Sun, 11 Aug 2013 18:44:37 +0000 (20:44 +0200)]
Make it optional to generate the <enclosure/> element

9 years agoUse getopt() to parse command line options
Antonio Ospite [Sun, 11 Aug 2013 18:27:36 +0000 (20:27 +0200)]
Use getopt() to parse command line options

This will make it easier to add more options.