README.rst 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. `gnusrss <#gnusrss>`__
  2. `English <#english>`__
  3. - `About <#about>`__
  4. - `Features <#features>`__
  5. - `Requirements <#requirements>`__
  6. - `Git repository <#git-repository>`__
  7. - `Install <#install>`__
  8. - `Configuration <#configuration>`__
  9. - `Crontab <#crontab>`__
  10. - `Use with twitter2rss and/or GNU
  11. Social <#use-with-twitter2rss-and/or-gnu-social>`__
  12. - `License <#license>`__
  13. `Castellano <#castellano>`__
  14. - `Acerca de <#acerca-de>`__
  15. - `Features <#features>`__
  16. - `Requisitos <#requisitos>`__
  17. - `Repositorio git <#repositorio-git>`__
  18. - `Instalación <#instalación>`__
  19. - `Configuración <#configuración>`__
  20. - `Crontab <#crontab>`__
  21. - `Uso con twitter2rss y/o GNU
  22. Social <#uso-con-twitter2rss-y/o-gnu-social>`__
  23. - `Bugs <#bugs>`__
  24. - `Licencia <#licencia>`__
  25. 1 gnusrss
  26. ---------
  27. 1.1 English
  28. ~~~~~~~~~~~
  29. 1.1.1 About
  30. ^^^^^^^^^^^
  31. gnusrss parse feeds and post them to GNU Social. The idea of ​​this program came from `spigot <https://github.com/nathans/spigot>`_, a program that posts feeds to the social network `pump.io <https://pump.io>`_ as does gnusrss but better, because it controls the possible flood. gnusrss does not have this option and it will be managed with the crontab (for now).
  32. 1.1.2 Features
  33. ^^^^^^^^^^^^^^
  34. - Multiple feed and GNU Social accounts support
  35. - sqlite3 is used to store the feeds
  36. - Can fetch RSS files or url indistinctly
  37. - Twitter image upload support when used with `twitter2rss <http://daemons.cf/cgit/twitter2rss>`_
  38. 1.1.3 Requirements
  39. ^^^^^^^^^^^^^^^^^^
  40. Need a version equal to or greater than python 3 and some libraries:
  41. - `feedparser <//pypi.python.org/pypi/feedparser>`_ >= 5.0
  42. - `requests <https://pypi.python.org/pypi/requests/2.11.1>`_ >= 2.11.1
  43. 1.1.4 Git repository
  44. ^^^^^^^^^^^^^^^^^^^^
  45. It's in two places:
  46. - `http://daemons.cf/cgit/gnusrss <http://daemons.cf/cgit/gnusrss>`_: the original repository
  47. - `https://notabug.org/drymer/gnusrss/ <https://notabug.org/drymer/gnusrss/>`_: A mirror in which it can be put issues and feature requests
  48. 1.1.5 Install
  49. ^^^^^^^^^^^^^
  50. As with any program that uses python, it should be used a virtual environment (virtualenv), but that is user selectable. It's possible to use one of the next installation methods:
  51. Install via pip:
  52. .. code-block:: sh
  53. :number-lines: 0
  54. $ su -c "pip3 install gnusrss"
  55. Clone the repository:
  56. .. code-block:: sh
  57. :number-lines: 0
  58. $ git clone git://daemons.cf/gnusrss
  59. # OR ...
  60. $ git clone https://notabug.org/drymer/gnusrss/
  61. $ cd gnusrss
  62. $ su -c "pip3 install -r requirements.txt"
  63. $ su -c "python3 setup.py install"
  64. If on parabola:
  65. .. code-block:: sh
  66. :number-lines: 0
  67. $ su -c "pacman -S gnusrss"
  68. 1.1.6 Configuration
  69. ^^^^^^^^^^^^^^^^^^^
  70. The program is (or should be) quite intuitive. Running the following, should show the basics:
  71. .. code-block:: sh
  72. :number-lines: 0
  73. $ gnusrss.py
  74. usage: gnusrss [-h] [-c file_name] [-C] [-p config_file] [-P] [-k file_name]
  75. Post feeds to GNU Social
  76. optional arguments:
  77. -h, --help show this help message and exit
  78. -c file_name, --create-config file_name
  79. creates a config file
  80. -C, --create-db creates the database
  81. -p config_file, --post config_file
  82. posts feeds
  83. -P, --post-all posts all feeds
  84. -k file_name, --populate-database file_name
  85. fetch the RSS and save it in the database
  86. In any case, if not clear, read the following.
  87. For the first use, it must be created the database and the first configuration file. This can done using the same command, like this:
  88. .. code-block:: sh
  89. :number-lines: 0
  90. $ gnusrss.py --create-db --create-config daemons
  91. Then it will ask several questions to create the first configuration file. It should look like this:
  92. .. code-block:: text
  93. :number-lines: 0
  94. Database created!
  95. Hi! Now we'll create config file!
  96. Please enter the feed's URL: https://daemons.cf/rss.xml
  97. Please enter your username (user@server.com): drymer@quitter.se
  98. Please enter your password: falsePassword
  99. Do you need to shorten the URLs that you 'post? Please take in account
  100. That You should only use it if your node only have 140 characters.
  101. Answer with "yes" or just press enter if you do not want to use it:
  102. Please enter your feed's fallbackurl. If you do not want or have one,
  103. just press enter:
  104. Now we're gona fetch the feed. Please wait ...
  105. Done! The tags are:
  106. tags
  107. title_detail
  108. link
  109. authors
  110. links
  111. author_detail
  112. published_parsed
  113. title
  114. summary
  115. id
  116. author
  117. published
  118. guidislink
  119. summary_detail
  120. The XML has-been parsed. Choose wich format you want:
  121. Please put the tags inside the square brackets
  122. Ex: {title} - {link} by @{author}: {title} - {link} by @{author}
  123. Do you want to allow insecure connection to your GNU social server?
  124. Answer with "yes" or just press enter if you don't want to use it:
  125. Do you want to populate the database? (y) Or you prefer to post old items? (n)
  126. The file is saved under the name 'daemons.ini'. It should look like this:
  127. .. code-block:: text
  128. :number-lines: 0
  129. [Feeds]
  130. feed = https://daemons.cf/rss.xml
  131. user = drymer@quitter.se
  132. password = falsePassword
  133. shorten =
  134. fallback_feed =
  135. format = {title} - {link} by @ {author}
  136. It can create all the configuration files you want.
  137. When creating the above file, it put into the database all the feeds that had so far. Thus, when running **gnusrss** for the first time, it will not post nothing to GNU Social until the feed has new information.
  138. To post feeds from a concrete config file or all execute, respectively, the following:
  139. .. code-block:: sh
  140. :number-lines: 0
  141. $ gnusrss.py -p daemons.ini
  142. $ gnusrss.py -P
  143. If the config file is created manually and the user don't want to post all the feed's content, just use the --populate-database option to save them to the database:
  144. .. code-block:: sh
  145. :number-lines: 0
  146. $ gnusrss.py -k otherFile.ini
  147. 1.1.7 Crontab
  148. ^^^^^^^^^^^^^
  149. The recommended way to execute **gnurss** is using the crontab. Each time it's run, a single item of the feed will be posted to prevent flood. Depending on the number of feeds that are published, you should choose a different runtime. For a blog that publishs once a day, it could be used the following:
  150. .. code-block:: sh
  151. :number-lines: 0
  152. $ crontab -e
  153. # A file is open and gets the following
  154. * 12 * * * cd $rutaDEgnusrss && gnusrss.py -p daemons.ini
  155. So it runs once, every day at midday. If, however, it's used with `twitter2rss <http://daemons.cf/cgit/twitter2rss/>`_, it could be recommended putting it to run every five minutes. It has to be remembered that is important to run in the directory where the database was created, because is where it will search it..
  156. 1.1.8 Use with twitter2rss and/or GNU Social
  157. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  158. It works like any feed, except for the field that is published. In both you have to choose ``{summary}``. An example configuration file is as follows:
  159. .. code-block:: text
  160. :number-lines: 0
  161. [feeds]
  162. feed = https://quitter.se/api/statuses/user_timeline/127168.atom
  163. user = drymer@quitter.se
  164. password = falsePassword
  165. shorten =
  166. fallback_feed =
  167. format = {summary}
  168. The feed can be achieved by looking at the source code of the page of the account you want. For `twitter2rss <http://daemons.cf/cgit/twitter2rss>`_, you can host it or can use this `web <http://daemons.cf/twitter2rss>`_.
  169. 1.1.9 License
  170. ^^^^^^^^^^^^^
  171. .. code-block:: text
  172. :number-lines: 0
  173. This program is free software: you can redistribute it and / or modify
  174. it under the terms of the GNU General Public License as published by
  175. the Free Software Foundation, Either version 3 of the License, or
  176. (At your option) any later version.
  177. This program is distributed in the hope That it will be useful,
  178. but WITHOUT ANY WARRANTY; without even the implied warranty of
  179. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  180. GNU General Public License for more details.
  181. You should have received a copy of the GNU General Public License
  182. Along With This Program. If not, see <http://www.gnu.org/licenses/>.
  183. 1.2 Castellano
  184. ~~~~~~~~~~~~~~
  185. 1.2.1 Acerca de
  186. ^^^^^^^^^^^^^^^
  187. gnusrss parsea feeds y los postea en GNU Social. La idea de hacer este programa surgió de `spigot <https://github.com/nathans/spigot>`_, un programa que postea feeds en la red social `pump.io <https://pump.io>`_ igual que hace gnusrss pero mejor, ya que controla el posible flood. gnusrss no tiene esta opción y se controlará con el propio crontab (de momento).
  188. 1.2.2 Features
  189. ^^^^^^^^^^^^^^
  190. - Soporta múltiples feeds y cuentas de GNU Social
  191. - sqlite3 es usado para guardar los feeds
  192. - Se puede usar tanto archivos RSS cómo url indistintamente
  193. - Soporta la súbida de imágenes de Twitter cuando es usado en conjunto con `twitter2rss <http://daemons.cf/cgit/twitter2rss>`_
  194. 1.2.3 Requisitos
  195. ^^^^^^^^^^^^^^^^
  196. Necesita una versión de python igual o superior a la 3 y algunas librerias:
  197. - `feedparser <https://pypi.python.org/pypi/feedparser>`_ >= 5.0
  198. - `requests <https://pypi.python.org/pypi/requests/2.11.1>`_ >= 2.11.1
  199. 1.2.4 Repositorio git
  200. ^^^^^^^^^^^^^^^^^^^^^
  201. Está en dos sitios:
  202. - `http://daemons.cf/cgit/gnusrss <http://daemons.cf/cgit/gnusrss>`_: el repositorio original
  203. - `https://notabug.org/drymer/gnusrss/ <https://notabug.org/drymer/gnusrss/>`_: un mirror, en el que se pueden poner los problemas y sugerencias de mejoras
  204. 1.2.5 Instalación
  205. ^^^^^^^^^^^^^^^^^
  206. Cómo con cualquier programa con python, es recomendable usar un entorno virtual (virtualenv), pero eso queda a elección del usuario. Se puede escoger entre los siguientes metodos:
  207. Instalar usando pip:
  208. .. code-block:: sh
  209. :number-lines: 0
  210. $ su -c "pip3 install gnusrss"
  211. Clonar el repositorio:
  212. .. code-block:: sh
  213. :number-lines: 0
  214. $ git clone git://daemons.cf/gnusrss
  215. # O ...
  216. $ git clone https://notabug.org/drymer/gnusrss/
  217. $ cd gnusrss
  218. $ su -c "pip3 install -r requirements.txt"
  219. $ su -c "python3 setup.py install"
  220. Si se usa parabola:
  221. .. code-block:: sh
  222. :number-lines: 0
  223. $ su -c "pacman -S gnusrss"
  224. 1.2.6 Configuración
  225. ^^^^^^^^^^^^^^^^^^^
  226. El programa es (o debería ser) bastante intuitivo. Ejecutando lo siguiente, deberia verse lo básico:
  227. .. code-block:: sh
  228. :number-lines: 0
  229. $ gnusrss.py
  230. usage: gnusrss [-h] [-c file_name] [-C] [-p config_file] [-P] [-k file_name]
  231. Post feeds to GNU Social
  232. optional arguments:
  233. -h, --help show this help message and exit
  234. -c file_name, --create-config file_name
  235. creates a config file
  236. -C, --create-db creates the database
  237. -p config_file, --post config_file
  238. posts feeds
  239. -P, --post-all posts all feeds
  240. -k file_name, --populate-database file_name
  241. fetch the RSS and save it in the database
  242. En cualquier caso, si no queda claro, leer lo siguiente.
  243. Para el primer uso, la base de datos y el primer archivo de configuración deben ser creados. Podemos hacerlo usando la misma orden, tal que así:
  244. .. code-block:: sh
  245. :number-lines: 0
  246. $ gnusrss.py --create-db --create-config daemons
  247. A continuación hará varias preguntas para configurar el primer archivo de configuración. Debería verse así:
  248. .. code-block:: text
  249. :number-lines: 0
  250. Database created!
  251. Hi! Now we'll create de config file!
  252. Please introduce the feed's url: https://daemons.cf/rss.xml
  253. Please introduce your username (user@server.com): drymer@quitter.se
  254. Please introduce your password: contraseñaFalsa
  255. {1}Do you need to shorten the urls that you post? Please take in account
  256. that you should only use it if your node only has 140 characters.
  257. Answer with "yes" or just press enter if you don't want to use it:
  258. {2}Please introduce your feed's fallbackurl. If you don't want or have one,
  259. just press enter:
  260. Now we're gona fetch the feed. Please wait...
  261. Done! The tags are:
  262. tags
  263. title_detail
  264. link
  265. authors
  266. links
  267. author_detail
  268. published_parsed
  269. title
  270. summary
  271. id
  272. author
  273. published
  274. guidislink
  275. summary_detail
  276. The XML has been parsed. Choose wich format you want:
  277. {3}Please put the tags inside the square brackets
  278. Ex: {title} - {link} by @{author}: {title} - {link} by @{author}
  279. {4}Do you want to allow insecure connection to your GNU social server?
  280. Answer with "yes" or just press enter if you don't want to use it:
  281. {5}Do you want to populate the database? (y) Or you prefer to post old items? (n)
  282. A continuación traduciré las lineas con los números entre corchetes.
  283. {1} Necesitas acortar las url que quieres postear? Por favor ten en cuenta que sólo deberia usarse si el servidor sólo tiene 140 carácteres.
  284. {2} Por favor introduce tu feed de emergencia. Si no tienes uno, solamente aprieta enter.
  285. {3} Por favor pon las etiquetas dentro de los corchetes.
  286. {4} Quieres permitir conexiones inseguras a tu servidor GNU social? Responde con "si" o simplemente apreta enter si no necesitas usarlo.
  287. {5} Quieres llenar la base de datos? (y) O prefieres publicar los artículos antiguos? (n)
  288. Respecto al 3, hay que examinar el código fuente del RSS para saber cuales interesan. En general, el que hay de ejemplo será lo que se busque. En el caso 4, sólo es útil si el servidor usa un certificado auto-firmado.
  289. El archivo se guardará con el nombre 'daemons.ini'. Después de todas estas preguntas, debería verse similar a esto:
  290. .. code-block:: text
  291. :number-lines: 0
  292. [feeds]
  293. feed = https://daemons.cf/rss.xml
  294. user = drymer@quitter.se
  295. password = contraseñaFalsa
  296. shorten =
  297. fallback_feed =
  298. format = {title} - {link} by @{author}
  299. insecure =
  300. Se pueden crear todos los archivos de configuración que se quieran.
  301. Al haber creado el archivo anterior, se han metido en la base de datos todos los feeds que habian hasta el momento. Por lo tanto, cuando se ejecuta **gnusrss** por primera vez, no posteará nada en GNU Social, a menos que el feed tenga nueva información.
  302. Para postear los feeds de un archivo o todos, ejecutar, respectivamente, lo siguiente:
  303. .. code-block:: sh
  304. :number-lines: 0
  305. $ gnusrss.py -p daemons.ini
  306. $ gnusrss.py -P
  307. Si el archivo de configuración ha sido creado manualmente y no se quiere postear el contenido del feed, sólo hay que ejecutar la opción --populate-database para guardar estos en la base de datos:
  308. .. code-block:: sh
  309. :number-lines: 0
  310. $ gnusrss.py -k otherFile.ini
  311. 1.2.7 Crontab
  312. ^^^^^^^^^^^^^
  313. El modo recomendado de ejecución de gnusrss es usando el crontab. Cada vez que se ejecute posteará un sólo elemento del feed para evitar el flood. Según la cantidad de feeds que se publiquen, se deberia escoger un tiempo de ejecución distinto. Para un blog que publique una vez al día, con poner lo siguiente, deberia valer:
  314. .. code-block:: sh
  315. :number-lines: 0
  316. $ crontab -e
  317. # Se abrirá un archivo y se mete lo siguiente
  318. * 12 * * * cd $rutaDEgnusrss && gnusrss.py -p daemons.cf
  319. Así se ejecuta una vez al día, a las doce de la mañana. Si, en cambio, lo usasemos con `twitter2rss <http://daemons.cf/cgit/twitter2rss/>`_, se recomienda poner que se ejecute cada cinco minutos. Hay que recordar que es importante que se ejecute en el directorio en el que se ha creado la base de datos, ya que es ahí dónde la buscará.
  320. 1.2.8 Uso con twitter2rss y/o GNU Social
  321. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  322. Funciona igual que con cualquier feed, exceptuando el campo que se publica. En ambos hay que escoger ``{summary}``. Un ejemplo de archivo de configuración sería el siguiente:
  323. .. code-block:: text
  324. :number-lines: 0
  325. [feeds]
  326. feed = https://quitter.se/api/statuses/user_timeline/127168.atom
  327. user = drymer@quitter.se
  328. password = contraseñaFalsa
  329. shorten =
  330. fallback_feed =
  331. format = {summary}
  332. El feed se puede conseguir mirando el código fuente de la página de la cuenta que se quiere. En el caso de `twitter2rss <http://daemons.cf/cgit/twitter2rss>`_, se puede hostear o se puede usar esta `web <http://daemons.cf/twitter2rss>`_. No es recomendable usarlo con ningún nodo que use 140 carácteres, ya que en los retweets se añade un símbolo, "♻", lo cual hará que un tweet de 140 carácteres no sea posteado.
  333. 1.2.9 Bugs
  334. ^^^^^^^^^^
  335. 1.2.10 Licencia
  336. ^^^^^^^^^^^^^^^
  337. .. code-block:: text
  338. :number-lines: 0
  339. This program is free software: you can redistribute it and/or modify
  340. it under the terms of the GNU General Public License as published by
  341. the Free Software Foundation, either version 3 of the License, or
  342. (at your option) any later version.
  343. This program is distributed in the hope that it will be useful,
  344. but WITHOUT ANY WARRANTY; without even the implied warranty of
  345. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  346. GNU General Public License for more details.
  347. You should have received a copy of the GNU General Public License
  348. along with this program. If not, see <http://www.gnu.org/licenses/>.