├── .github └── ISSUE_TEMPLATE.md ├── .gitignore ├── Cask ├── LICENSE ├── Makefile ├── README.md ├── elfeed-protocol-common.el ├── elfeed-protocol-fever.el ├── elfeed-protocol-newsblur.el ├── elfeed-protocol-owncloud.el ├── elfeed-protocol-ttrss.el ├── elfeed-protocol.el └── test ├── elfeed-protocol-fever-test.el ├── elfeed-protocol-newsblur-test.el ├── elfeed-protocol-owncloud-test.el ├── elfeed-protocol-test.el ├── elfeed-protocol-ttrss-test.el ├── fixtures ├── fever │ ├── categories.json │ ├── entries.json │ └── feeds.json ├── newsblur │ ├── entries.json │ └── feeds.json ├── owncloud │ ├── categories.json │ ├── entries.json │ └── feeds.json └── ttrss │ ├── categories.json │ ├── entries-no-feed-id.json │ ├── entries.json │ └── feeds.json ├── test-checkdoc.el └── test-helper.el /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | - OS version: `???` 2 | - emacs version: `???` 3 | - elfeed version: `???` 4 | - elfeed-protocol version: `???` 5 | - curl version: `???` 6 | - server version: `???` (docker image and tag) 7 | - is variable `elfeed-protocol-xxx-feeds` empty: `yes/no` 8 | 9 | **elfeed-log** 10 | 11 | Please collect logs in buffer `*elfeed-log*` with the following config 12 | before reporting issues: 13 | 14 | ```emacs-lisp 15 | (setq elfeed-log-level 'debug) 16 | (toggle-debug-on-error) 17 | 18 | ;; for more logs if necessary 19 | (setq elfeed-protocol-log-trace t) 20 | (setq elfeed-protocol-fever-maxsize 5) 21 | (setq elfeed-protocol-owncloud-maxsize 5) 22 | (setq elfeed-protocol-ttrss-maxsize 5) 23 | (setq elfeed-protocol-newsblur-maxpages 1) 24 | ``` 25 | 26 | **error backtrace** 27 | 28 | ``` 29 | ``` 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .cask* 2 | *.elc 3 | __** 4 | .* 5 | -------------------------------------------------------------------------------- /Cask: -------------------------------------------------------------------------------- 1 | (source gnu) 2 | ;(source melpa) 3 | (source melpa-stable) 4 | 5 | (package-file "elfeed-protocol.el") 6 | 7 | (files "elfeed-*.el") 8 | 9 | (depends-on "elfeed") 10 | (depends-on "package-lint") 11 | 12 | (development 13 | (depends-on "xtest") 14 | (depends-on "ert-runner")) 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | EMACS ?= emacs 2 | CASK ?= cask 3 | 4 | .PHONY: install build test clean 5 | all: install build test clean 6 | 7 | # init cask environment 8 | init: 9 | EMACS=$(EMACS) $(CASK) install --verbose 10 | 11 | build: 12 | EMACS=$(EMACS) $(CASK) build 13 | 14 | test: 15 | EMACS=$(EMACS) $(CASK) exec ert-runner 16 | 17 | clean: 18 | EMACS=$(EMACS) $(CASK) clean-elc 19 | 20 | checkdoc: 21 | $(CASK) exec $(EMACS) --batch -L . -l test/test-checkdoc.el -Q 2>&1 | tee __checkdoc 22 | @cat __checkdoc | [ $$(wc -l) -gt 0 ] && exit 1 || exit 0 23 | 24 | elint: 25 | $(CASK) exec $(EMACS) --batch -L . --eval="(elint-directory \".\")" 26 | 27 | package-lint: 28 | $(CASK) exec $(EMACS) --batch -L . -l elfeed.el -l package-lint.el -f package-lint-batch-and-exit elfeed-protocol.el 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > [!IMPORTANT] 2 | > Since version `0.9.0` , elfeed-protocol use variable 3 | > `elfeed-protocol-feeds` instead of `elfeed-feeds` to fix conflict 4 | > issues to extensions that modify or require `elfeed-feeds`. And 5 | > elfeed-protocol could work together with elfeed-org and 6 | > elfeed-autotag without any aditional setup now. 7 | 8 | elfeed-protocol 9 | ============== 10 | [![MELPA](http://melpa.org/packages/elfeed-protocol-badge.svg)](http://melpa.org/#/elfeed-protocol) [![MELPA Stable](https://stable.melpa.org/packages/elfeed-protocol-badge.svg)](https://stable.melpa.org/#/elfeed-protocol) 11 | 12 | Provide extra protocols to make self-hosting RSS readers work 13 | with [elfeed](https://github.com/skeeto/elfeed), 14 | including 15 | [Fever](https://feedafever.com/api), 16 | [NewsBlur](https://newsblur.com/), 17 | [Nextcloud/ownCloud News](https://nextcloud.com/), 18 | [Tiny Tiny RSS](https://tt-rss.org/fox/tt-rss) and even more. 19 | 20 | # Installation through MELPA 21 | 22 | ``` 23 | ;; Install through package manager 24 | M-x package-install 25 | elfeed-protocol 26 | ``` 27 | 28 | # Initialization 29 | Setup elfeed-protocol, then switch to search view and and press G to update entries: 30 | 31 | ```emacs-lisp 32 | ;; curl recommend 33 | (setq elfeed-use-curl t) 34 | (elfeed-set-timeout 36000) 35 | (setq elfeed-curl-extra-arguments '("--insecure")) ;necessary for https without a trust certificate 36 | 37 | ;; setup feeds 38 | (setq elfeed-protocol-feeds '(("owncloud+https://user@myhost.com" 39 | :password "my-password"))) 40 | 41 | ;; enable elfeed-protocol 42 | (setq elfeed-protocol-enabled-protocols '(fever newsblur owncloud ttrss)) 43 | (elfeed-protocol-enable) 44 | ``` 45 | 46 | # Protocol Details 47 | 48 | ## fever (Fever) 49 | 1. Fetch articles with the entry ID one by one by default. For some 50 | service that don't provide valid entry ID like FressRSS, just set 51 | `elfeed-protocol-fever-update-unread-only` to t as a workaround 52 | 1. Fetch remote category as tag 53 | 1. Support sync unread, starred(saved) tags, the starred tag name 54 | defined in `elfeed-protocol-fever-star-tag` which default value is 55 | `star` 56 | 1. Support multiple fetching methods: 57 | - `elfeed-protocol-fever-update-older` 58 | - `elfeed-protocol-fever-update-star` 59 | 60 | **NOTE**: Many self-hosted RSS server provide Fever API, and user must 61 | provide the URL manually. Here is a list of Fever API URLs I collected 62 | for some popular RSS servers: 63 | 64 | - Tiny Tiny RSS's Fever plugin 65 | ``` 66 | https://your-ttrss-server/plugins/fever/ 67 | ``` 68 | - FreshRSS 69 | ``` 70 | https://your-freshrss-server/api/fever.php 71 | ``` 72 | - miniflux 73 | ``` 74 | https://your-miniflux-server/fever/ 75 | ``` 76 | 77 | Example: 78 | ```emacs-lisp 79 | (setq elfeed-protocol-fever-update-unread-only nil) 80 | (setq elfeed-protocol-fever-fetch-category-as-tag t) 81 | (setq elfeed-protocol-feeds '(("fever+https://user@myhost.com" 82 | :api-url "https://myhost.com/plugins/fever/" 83 | :password "my-password"))) 84 | ``` 85 | 86 | ## newsblur (NewsBlur) 87 | 1. Fetch articles from recent pages 88 | 1. Fetch articles for special feed 89 | 1. Fetch remote category as tag 90 | 1. Fetch tags in remote 91 | 1. Support sync unread, starred(saved) tags, the starred tag name 92 | defined in `elfeed-protocol-ttrss-star-tag` which default value is 93 | `star` 94 | 95 | **NOTE**: A file for storing session cookies has to be specified via 96 | `elfeed-curl-extra-arguments` like in the following example. 97 | 98 | Example: 99 | ```emacs-lisp 100 | (setq elfeed-protocol-newsblur-maxpages 20) 101 | (setq elfeed-protocol-newsblur-fetch-tags t) 102 | (setq elfeed-protocol-newsblur-fetch-category-as-tag t) 103 | (setq elfeed-protocol-newsblur-sub-category-separator "/") 104 | (setq elfeed-curl-extra-arguments '("--cookie-jar" "/tmp/newsblur-cookie" 105 | "--cookie" "/tmp/newsblur-cookie")) 106 | (setq elfeed-protocol-feeds '(("newsblur+https://user@newsblur.com" 107 | :password "my-password"))) 108 | ``` 109 | 110 | ## owncloud (ownCloud News) 111 | 1. Fetch articles with the modified time by default 112 | 1. Fetch articles for special feed 113 | 1. Fetch remote category as tag 114 | 1. Support sync unread and starred tags, the starred tag name defined 115 | in `elfeed-protocol-owncloud-star-tag` which default value is `star`. For 116 | example, if user add `star` tag to one article, the star stat will 117 | be sync to server, too 118 | 1. Support multiple fetching methods: 119 | - `elfeed-protocol-owncloud-update-since-timestamp` 120 | - `elfeed-protocol-owncloud-update-since-id` 121 | - `elfeed-protocol-owncloud-update-older` 122 | 123 | Example: 124 | ```emacs-lisp 125 | (setq elfeed-protocol-owncloud-maxsize 1000) 126 | (setq elfeed-protocol-owncloud-update-with-modified-time t) 127 | (setq elfeed-protocol-owncloud-fetch-category-as-tag t) 128 | (setq elfeed-protocol-feeds '(("owncloud+https://user@myhost.com" 129 | :password "my-password"))) 130 | ``` 131 | 132 | ## ttrss (Tiny Tiny RSS, requires version: 1.7.6) 133 | 1. Fetch articles by the entry ID 134 | 1. Fetch articles for special feed 135 | 1. Fetch remote category as tag 136 | 1. Support sync unread, starred and published tags, the starred tag 137 | name defined in `elfeed-protocol-ttrss-star-tag` which default 138 | value is `star`, and the published tag name defined in 139 | `elfeed-protocol-ttrss-publish-tag` which default value is 140 | `publish` 141 | 1. Support multiple fetching methods: 142 | - `elfeed-protocol-ttrss-update-older` 143 | - `elfeed-protocol-ttrss-update-star` 144 | 145 | **NOTE**: For Tiny Tiny RSS only allow fetch Maximize 200 entries each 146 | time, so if your own much more starred entries, just run 147 | `elfeed-protocol-ttrss-update-star` manually to fetch them all 148 | 149 | Example: 150 | ```emacs-lisp 151 | (setq elfeed-protocol-ttrss-maxsize 200) ; bigger than 200 is invalid 152 | (setq elfeed-protocol-ttrss-fetch-category-as-tag t) 153 | (setq elfeed-protocol-feeds '(("ttrss+https://user@myhost.com" 154 | :password "my-password"))) 155 | ``` 156 | 157 | # Extra settings 158 | 159 | ## All example formats for elfeed-protocol-feeds 160 | 161 | ```emacs-lisp 162 | (setq elfeed-protocol-feeds '( 163 | ;; same format with elfeed-feeds 164 | "http://foo/" 165 | ("http://baz/" comic) 166 | 167 | ;; format 1 168 | "owncloud+https://user:pass@myhost.com" 169 | 170 | ;; format 2, for username or password with special characters 171 | ("owncloud+https://user@domain.com@myhost.com" 172 | :password "password/with|special@characters:") 173 | 174 | ;; format 3, for password in file 175 | ("owncloud+https://user@myhost.com" 176 | :password-file "~/.password") 177 | 178 | ;; format 4, for password in .authinfo, 179 | ;; ensure (auth-source-search :host "myhost.com" :port "443" :user "user4") exists 180 | ("owncloud+https://user@myhost.com" 181 | :use-authinfo t) 182 | 183 | ;; format 5, for password in gnome-keyring 184 | ("owncloud+https://user@myhost.com" 185 | :password (shell-command-to-string "echo -n `secret-tool lookup attribute value`")) 186 | 187 | ;; format 6, for password in pass(1), using password-store.el 188 | ("owncloud+https://user@myhost.com" 189 | :password (password-store-get "owncloud/app-pass")) 190 | 191 | ;; use autotags 192 | ("owncloud+https://user@myhost.com" 193 | :password "password" 194 | :autotags (("example.com" comic))))) 195 | ``` 196 | 197 | ## Work with feeds and autotags that defined in original elfeed-feeds 198 | 199 | ```emacs-lisp 200 | (setq elfeed-feeds '("http://foo/" ("http://baz/" comic))) 201 | (setq elfeed-protocol-feeds '(("owncloud+https://user@myhost.com" 202 | :password "my-password"))) 203 | (setq elfeed-protocol-feeds (append elfeed-protocol-feeds elfeed-feeds)) 204 | ``` 205 | 206 | ## Work with elfeed-org and elfeed-autotag 207 | 208 | Since version `0.9.0`, elfeed-protocol could work together with 209 | elfeed-org and elfeed-autotag without any aditional setup. 210 | 211 | ## Work with elfeed-summary 212 | 213 | To fix `0 / 0` zero count issue for all feeds, just active the 214 | following advice for `rmh-elfeed-org-export-feed`: 215 | 216 | ```emacs-lisp 217 | (defun elfeed-protocol-advice-rmh-elfeed-org-export-feed (headline) 218 | "Advice for `rmh-elfeed-org-export-feed', add elfeed-protocol ID as suffix for each feed." 219 | (let* ((url (car headline)) 220 | (proto-id (car (elfeed-protocol-feed-list)))) 221 | (when proto-id 222 | (setcar headline (elfeed-protocol-format-subfeed-id proto-id url))))) 223 | (advice-add 'rmh-elfeed-org-export-feed :before #'elfeed-protocol-advice-rmh-elfeed-org-export-feed) 224 | ``` 225 | 226 | Besides, don't use `elfeed-summary-update` to fetach articles, 227 | use `elfeed-update` instead, and press `r` to refresh UI manually: 228 | ```emacs-lisp 229 | (define-key elfeed-summary-mode-map (kbd "R") #'elfeed-update) 230 | ``` 231 | 232 | # Run Unit-Tests 233 | 234 | Install `cask` system package firstly, and then run following commands 235 | 236 | ```shell 237 | make init 238 | make test 239 | make checkdoc 240 | make elint 241 | make package-lint 242 | ``` 243 | 244 | # Deploy Services for Testing 245 | ## Nextcloud/ownCloud News 246 | 1. Fetch docker image and run it 247 | 248 | docker pull nextcloud 249 | docker run --rm -p 80:80 nextcloud 250 | 251 | 2. Open in browser to setup Nextcloud 252 | 1. Create admin user and select database to SQLite, then press "Finish setup" 253 | 2. Press left top popup menu and select "+Apps", select 254 | "Multimedia", and enable the "News" app 255 | 3. Press left top popup menu and switch to "News" app, then 256 | subscribe some feeds 257 | 258 | 3. Setup `elfeed-protocol` 259 | 260 | ```emacs-lisp 261 | (setq elfeed-protocol-feeds '("owncloud+http://:@localhost")) 262 | ``` 263 | 264 | ## Tiny Tiny RSS 265 | 1. Fetch related docker images and run them 266 | 267 | docker pull clue/ttrss 268 | docker pull nornagon/postgres 269 | docker run --rm -d --name ttrssdb nornagon/postgres 270 | docker run --rm --link ttrssdb:db -p 80:80 clue/ttrss 271 | 272 | 2. Open in browser to setup Tiny Tiny RSS 273 | 1. Use the default `admin:password` authorization info to login 274 | 2. Enter "Preferences" page to enable "Enable API access" and save configuration 275 | 276 | 3. Setup `elfeed-protocol` 277 | 278 | ```emacs-lisp 279 | (setq elfeed-protocol-feeds '("ttrss+http://admin:password@localhost")) 280 | ``` 281 | 282 | # Report Issues 283 | 284 | Please collect logs in buffer `*elfeed-log*` with the following config 285 | before reporting issues: 286 | 287 | ```emacs-lisp 288 | (setq elfeed-log-level 'debug) 289 | (toggle-debug-on-error) 290 | 291 | ;; for more logs 292 | (setq elfeed-protocol-log-trace t) 293 | (setq elfeed-protocol-fever-maxsize 10) 294 | (setq elfeed-protocol-newsblur-maxpages 1) 295 | (setq elfeed-protocol-owncloud-maxsize 10) 296 | (setq elfeed-protocol-ttrss-maxsize 10) 297 | ``` 298 | 299 | # Q&A 300 | 301 | 1. When I run elfeed-update I get the error: `elfeed-protocol-feeds malformed, bad entry` 302 | 303 | Don't forget to enable elfeed-protocol at first: 304 | ```emacs-lisp 305 | (elfeed-protocol-enable) 306 | ``` 307 | 308 | 1. Not working if my password contains special characters like `@#$/:`. 309 | 310 | Use format 2 instead in previous example for complex password: 311 | ```emacs-lisp 312 | ;; format 2, for password with special characters 313 | ("owncloud+https://user@myhost.com" 314 | :password "password/with|special@characters:") 315 | ``` 316 | 317 | 1. How to fetch my older headlines in server? 318 | 319 | `fever`, `owncloud` and `ttrss` protocol provide method to fetch 320 | older headlines. And the update operations could not executed in 321 | the same time, so `run-at-time` with some delays(for example 15s) 322 | will help you: 323 | ```emacs-lisp 324 | (setq my-elfeed-update-timer 325 | (run-at-time 15 15 326 | (lambda () (when (= elfeed-curl-queue-active 0) 327 | (elfeed-protocol-ttrss-update-older "ttrss+https://user@host"))))) 328 | (cancel-timer my-elfeed-update-timer) 329 | ``` 330 | 331 | 1. Why the articles still are unread even they were mark read in other client? 332 | 333 | Well, only ownCloud News API support two-way synchronization for it 334 | fetch articles with modified time. And other API only fetch 335 | articles id by id. So your issue just the desired result~ 336 | 337 | However here is a workaround. For example fever, you could reset 338 | the update mark so it will re-fetch the last 1000 articles in 339 | following updates and will sync the read state: 340 | 341 | ```emacs-lisp 342 | (let* ((proto-id "fever+https://user@miniflux-host") 343 | (last-id (elfeed-protocol-fever-get-update-mark proto-id 'update))) 344 | (elfeed-protocol-fever-set-update-mark proto-id 'update (- last-id 1000))) 345 | ``` 346 | 347 | And Fever limit 50 max size for per request, so update timer may help you: 348 | 349 | ```emacs-lisp 350 | (run-at-time 300 300 351 | (lambda () (when (= elfeed-curl-queue-active 0) 352 | (elfeed-update)))) 353 | ``` 354 | 355 | Or you could use `elfeed-untag-1` mark all selected articles as 356 | read(will not call curl process) then execute 357 | `elfeed-protocol-fever-reinit` fetch all unread articles: 358 | 359 | ```emacs-lisp 360 | (cl-loop for entry in (elfeed-search-selected) 361 | do (elfeed-untag-1 entry 'unread)) 362 | ``` 363 | 364 | Hope helps. 365 | 366 | 1. Sometimes emacs may be blocked if the parsing downloaded articles 367 | is too large, for example >50MB. 368 | 369 | This is caused by the known emacs bug that CPU will be in high 370 | usage if a text line is too long. There three methods to workaround 371 | this: 372 | 1. Method 1, limit the download size, for example: 373 | 374 | (setq elfeed-protocol-owncloud-maxsize 1000) 375 | 376 | 1. Method 2, for ownCloud, just update articles since special entry 377 | ID instead the modified time, this could run multiple times to 378 | keep up to date to avoid download too large entries once time 379 | 380 | M-x elfeed-protocol-owncloud-update-since-id 381 | 382 | 1. Method 3, some protocol provide update method to reset the last 383 | modified time to skip some data, for example: 384 | 385 | M-x elfeed-protocol-owncloud-update-since-timestamp 386 | 387 | # Donation 388 | 389 | - BTC [3DMLQ8f4Ui5Adka9Y44MVM2cKT6yBVZdY5](https://www.blockchain.com/btc/address/3DMLQ8f4Ui5Adka9Y44MVM2cKT6yBVZdY5) 390 | - ETH [0x561c694EF2bf32C23759c4Abd7D132161DaE13F8](https://www.blockchain.com/eth/address/0x561c694EF2bf32C23759c4Abd7D132161DaE13F8) 391 | 392 | # License 393 | 394 | Released under the terms of the GNU GPLv3+. 395 | -------------------------------------------------------------------------------- /elfeed-protocol-common.el: -------------------------------------------------------------------------------- 1 | ;;; elfeed-protocol-common.el --- elfeed-protocol variables and help functions -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | ;; elfeed-protocol variables and help functions 5 | 6 | ;;; Code: 7 | 8 | (require 'cl-lib) 9 | (require 'subr-x) 10 | (require 'elfeed) 11 | 12 | (defvar elfeed-protocol-log-trace nil 13 | "Show more logs than debug level.") 14 | 15 | (defvar elfeed-protocol-lazy-sync nil 16 | "If not nil, will synchronize read/unread/starred/unstarred states to remote 17 | server in next update operation.") 18 | 19 | (defconst elfeed-protocol-unknown-feed-url "unknown-feed") 20 | (defconst elfeed-protocol-unknown-feed-title "Unknown Feed") 21 | 22 | (defun elfeed-protocol-add-unknown-feed (proto-id) 23 | "Add unknown feed for fallback." 24 | (let* ((feed-url elfeed-protocol-unknown-feed-url) 25 | (feed-id (elfeed-protocol-format-subfeed-id 26 | proto-id feed-url)) 27 | (feed-title elfeed-protocol-unknown-feed-title) 28 | (feed-db (elfeed-db-get-feed feed-id))) 29 | (setf (elfeed-feed-url feed-db) feed-id 30 | (elfeed-feed-title feed-db) feed-title))) 31 | 32 | (defun elfeed-protocol-feed-p (url-or-feed) 33 | "Check if a URL-OR-FEED contain extra protocol." 34 | (let ((feed-url (if (elfeed-feed-p url-or-feed) 35 | (or (elfeed-feed-url url-or-feed) 36 | (elfeed-feed-id url-or-feed)) 37 | url-or-feed))) 38 | (eq 'string (type-of (elfeed-protocol-type feed-url))))) 39 | 40 | (defun elfeed-protocol-type (feed-url) 41 | "Get the protocol type in FEED-URL. 42 | For example \"owncloud+https://user@pass:host.com:443\" will return 43 | \"owncloud\". If there is no valid protocol type in FEED-URL, just return nil." 44 | (let* ((urlobj (url-generic-parse-url feed-url)) 45 | (type (url-type urlobj)) 46 | (list (when type (split-string type "+")))) 47 | (when (and list (eq 2 (length list))) 48 | (elt list 0)))) 49 | 50 | (defun elfeed-protocol-url (feed-url) 51 | "Get the protocol url in FEED-URL. 52 | For example \"owncloud+https://user@pass:host.com:443\" will return 53 | \"https://user@pass:host.com:443\". If there is no valid protocol type in 54 | FEED-URL, just return nil." 55 | (let ((proto-type (elfeed-protocol-type feed-url))) 56 | (when proto-type 57 | (replace-regexp-in-string 58 | (regexp-quote (concat proto-type "+")) "" feed-url)))) 59 | 60 | (defun elfeed-protocol-id (proto-type url) 61 | "Build a protocol id for PROTO-TYPE and URL." 62 | (concat proto-type "+" (elfeed-protocol-no-password-url url))) 63 | 64 | (defun elfeed-protocol-no-password-url (url) 65 | "Remove password field in URL is exists, user field will not change." 66 | (let* ((urlobj (url-generic-parse-url url)) 67 | (password (url-password urlobj))) 68 | (if password 69 | (replace-regexp-in-string 70 | (concat "\\(" ":" (regexp-quote password) "\\).*\\'") "" url nil nil 1) 71 | url))) 72 | 73 | (defun elfeed-protocol-no-auth-url (url) 74 | "Remove user and password fields in URL if exists." 75 | (let* ((urlobj (url-generic-parse-url url)) 76 | (user (url-user urlobj)) 77 | (password (if (url-password urlobj) (url-password urlobj) nil))) 78 | (replace-regexp-in-string 79 | (concat "\\(" (regexp-quote (if user user "")) 80 | "\\(:" (regexp-quote (if password password "")) 81 | "\\)?@\\).*\\'") "" url nil nil 1))) 82 | 83 | (defun elfeed-protocol-entry-protocol-id (entry) 84 | "Return protocol url id for specific ENTRY." 85 | (elfeed-meta entry :protocol-id)) 86 | 87 | (defun elfeed-protocol-format-subfeed-id (proto-id feed-url) 88 | "Build feed id for entry. 89 | Which just concat PROTO-ID and FEED-URL, for example 90 | \"owncloud+http://user@myhost.com::http://example.com/rss\"" 91 | (concat proto-id "::" feed-url)) 92 | 93 | (defun elfeed-protocol-host-url (url) 94 | "Get host url from the feed id style URL." 95 | (let ((list (split-string url "::"))) 96 | (if (eq 2 (length list)) 97 | (elt list 0) 98 | url))) 99 | 100 | (defun elfeed-protocol-subfeed-url (url) 101 | "Get sub feed url from the feed id style URL." 102 | (let ((list (split-string url "::"))) 103 | (when (eq 2 (length list)) 104 | (elt list 1)))) 105 | 106 | (defun elfeed-protocol-subfeed-p (url) 107 | "Check if a URL contain sub feed url." 108 | (eq 'string (type-of (elfeed-protocol-subfeed-url url)))) 109 | 110 | (defun elfeed-protocol-meta-feed (proto-id) 111 | "Get meta protocol feed object in `elfeed-protocol-feeds' for PROTO-ID." 112 | (catch 'found 113 | (dolist (feed elfeed-protocol-feeds) 114 | (let* ((feed-url (cl-typecase feed 115 | (list (when (stringp (car feed)) (car feed))) 116 | (string feed))) 117 | (feed-proto-id (elfeed-protocol-no-password-url feed-url))) 118 | (when (string-match (concat "^" (regexp-quote feed-proto-id)) proto-id) 119 | (throw 'found feed)))))) 120 | 121 | (defun elfeed-protocol-meta-url (proto-id) 122 | "Get meta protocol feed url in `elfeed-protocol-feeds' for PROTO-ID." 123 | (let* ((feed (elfeed-protocol-meta-feed proto-id)) 124 | (feed-url (cl-typecase feed 125 | (list (when (stringp (car feed)) (car feed))) 126 | (string feed)))) 127 | feed-url)) 128 | 129 | (defun elfeed-protocol-meta-data (proto-id prop) 130 | "Get meta property data in `elfeed-protocol-feeds` for PROTO-ID. 131 | PROP could be :password, :autotags etc." 132 | (let* ((feed (elfeed-protocol-meta-feed proto-id)) 133 | (proto-props (when (listp feed) (cdr feed)))) 134 | (plist-get proto-props prop))) 135 | 136 | (defun elfeed-protocol-meta-user (proto-id) 137 | "Get user property data in `elfeed-protocol-feeds` for PROTO-ID." 138 | (let* ((proto-url (elfeed-protocol-meta-url proto-id)) 139 | (urlobj (url-generic-parse-url (elfeed-protocol-url proto-url))) 140 | (user (url-user urlobj)) 141 | (host (url-host urlobj)) 142 | (host-list (split-string host "@"))) 143 | (if (>= (length host-list) 2) 144 | (concat user "@" (nth 0 host-list)) 145 | user))) 146 | 147 | (defun elfeed-protocol-meta-password (proto-id) 148 | "Get password property data in `elfeed-protocol-feeds` for PROTO-ID. 149 | Will try to get password from :password filed, url, passowrd file and .authinfo 150 | one by one." 151 | (let* ((proto-url (elfeed-protocol-meta-url proto-id)) 152 | (urlobj (url-generic-parse-url (elfeed-protocol-url proto-url))) 153 | (meta-pass (elfeed-protocol-meta-data proto-id :password))) 154 | (cond 155 | ((and meta-pass (stringp meta-pass)) 156 | meta-pass) 157 | 158 | ((and meta-pass (functionp meta-pass)) 159 | (funcall meta-pass)) 160 | 161 | ((and meta-pass (listp meta-pass) (functionp (car meta-pass))) 162 | (eval meta-pass)) 163 | 164 | ((url-password urlobj) (url-password urlobj)) 165 | 166 | ((elfeed-protocol-meta-data proto-id :password-file) 167 | (elfeed-protocol-get-string-from-file 168 | (elfeed-protocol-meta-data proto-id :password-file))) 169 | 170 | ((elfeed-protocol-meta-data proto-id :use-authinfo) 171 | (require 'auth-source) 172 | (let* ((auth-info (auth-source-search :host (url-host urlobj) 173 | :port (url-port urlobj) 174 | :user (url-user urlobj))) 175 | (secret (plist-get (car auth-info) :secret))) 176 | (if (functionp secret) (funcall secret) secret)))))) 177 | 178 | (defun elfeed-protocol-get-string-from-file (path) 179 | "Return file content in PATH." 180 | (with-temp-buffer 181 | (insert-file-contents path) 182 | (buffer-string))) 183 | 184 | (defun elfeed-protocol-meta-autotags (proto-id) 185 | "Get :autotags property data in `elfeed-protocol-feeds` for PROTO-ID." 186 | (let ((autotags (elfeed-protocol-meta-data proto-id :autotags))) 187 | (if (eq (car autotags) 'quote) 188 | (eval autotags) 189 | autotags))) 190 | 191 | (defun elfeed-protocol-feed-autotags (proto-id url-or-feed) 192 | "Return autotags for protocol feed. 193 | Similar with `elfeed-feed-autotags' but `elfeed-feeds' will be overrode by 194 | `:autotags' item that exists in protocol properties. Besides, it query autotags 195 | for both normal feed url and full subfeed url that with PROTO-ID as prefix. 196 | PROTO-ID is the protocol id and URL-OR-FEED is the traget child feed url under 197 | protocol feed" 198 | (let* ((meta-autotags (elfeed-protocol-meta-autotags proto-id)) 199 | (elfeed-feeds (if meta-autotags meta-autotags elfeed-feeds)) 200 | (autotags-subfeed (elfeed-feed-autotags url-or-feed)) 201 | (autotags-subfeed-id (elfeed-feed-autotags 202 | (elfeed-protocol-format-subfeed-id proto-id url-or-feed)))) 203 | (if autotags-subfeed 204 | autotags-subfeed 205 | autotags-subfeed-id))) 206 | 207 | (defun elfeed-protocol-get-feed-meta-data (proto-id key) 208 | "Get meta data in feed db. 209 | PROTO-ID is the target protocol feed id. KEY is the key name." 210 | (let* ((feed (elfeed-db-get-feed proto-id))) 211 | (elfeed-meta feed key))) 212 | 213 | (defun elfeed-protocol-set-feed-meta-data (proto-id key value) 214 | "Get meta data in feed db. 215 | PROTO-ID is the target protocol feed id. KEY is the key name. VALUE is the 216 | target value." 217 | (let* ((feed (elfeed-db-get-feed proto-id))) 218 | (setf (elfeed-meta feed key) value))) 219 | 220 | (defun elfeed-protocol-get-last-modified (proto-id) 221 | "Get last entry modified time. 222 | PROTO-ID is the target protocol feed id. If not initialized just return 0. The 223 | last modified time was saved in elfeed db as a mock feed." 224 | (let* ((last-modified (elfeed-protocol-get-feed-meta-data proto-id :last-modified))) 225 | (if last-modified 226 | last-modified 227 | 0))) 228 | (defun elfeed-protocol-set-last-modified (proto-id last-modified) 229 | "Set last entry modified time. 230 | PROTO-ID is the target protocol feed id. LAST-MODIFIED is the target value." 231 | (elfeed-protocol-set-feed-meta-data proto-id :last-modified last-modified)) 232 | 233 | (defun elfeed-protocol-get-first-entry-id (proto-id) 234 | "Get first entry id. 235 | PROTO-ID is the target protocol feed id. If not initialized, just return -1." 236 | (let* ((last-entry-id (elfeed-protocol-get-feed-meta-data proto-id :first-entry-id))) 237 | (if last-entry-id 238 | last-entry-id 239 | -1))) 240 | (defun elfeed-protocol-set-first-entry-id (proto-id first-entry-id) 241 | "Set first entry id to elfeed db. 242 | PROTO-ID is the target protocol feed id. FIRST-ENTRY-ID is the target value." 243 | (elfeed-protocol-set-feed-meta-data proto-id :first-entry-id first-entry-id)) 244 | 245 | (defun elfeed-protocol-get-last-entry-id (proto-id) 246 | "Get last entry id. 247 | PROTO-ID is the target protocol feed id. If not initialized, just return -1." 248 | (let* ((last-entry-id (elfeed-protocol-get-feed-meta-data proto-id :last-entry-id))) 249 | (if last-entry-id 250 | last-entry-id 251 | -1))) 252 | (defun elfeed-protocol-set-last-entry-id (proto-id last-entry-id) 253 | "Set last entry id to elfeed db. 254 | PROTO-ID is the target protocol feed id. LAST-ENTRY-ID is the target value." 255 | (elfeed-protocol-set-feed-meta-data proto-id :last-entry-id last-entry-id)) 256 | 257 | (defun elfeed-protocol-get-pending-ids (proto-id key) 258 | "Get read/unread/starred/unstarred pending ids that to synchronize later. 259 | PROTO-ID is the target protocol feed id. KEY could be :pending-read, 260 | :pending-unread, :pending-starred, :pending-unstarred, :pending-published and 261 | :pending-unpublished." 262 | (interactive (list (completing-read "Protocol Feed: " (elfeed-protocol-feed-list)) 263 | (intern (completing-read 264 | "Key name: " 265 | '(:pending-read :pending-unread :pending-starred :pending-unstarred 266 | :pending-published :pending-unpublished))))) 267 | (let* ((pending-ids (elfeed-protocol-get-feed-meta-data proto-id key))) 268 | (if (> (length pending-ids) 0) 269 | pending-ids 270 | nil))) 271 | (defun elfeed-protocol-set-pending-ids (proto-id key ids) 272 | "Set read/unread/starred/unstarred pending ids that to synchronize later. 273 | PROTO-ID is the target protocol feed id. KEY could be :pending-read, 274 | :pending-unread, :pending-starred, :pending-unstarred, :pending-published and 275 | :pending-unpublished. IDS is the id list." 276 | (interactive (list (completing-read "Protocol Feed: " (elfeed-protocol-feed-list)) 277 | (intern (completing-read 278 | "Key name: " 279 | '(:pending-read :pending-unread :pending-starred :pending-unstarred 280 | :pending-published :pending-unpublished))))) 281 | (elfeed-protocol-set-feed-meta-data proto-id key ids)) 282 | 283 | (defun elfeed-protocol-append-pending-ids (proto-id key ids) 284 | "Append pending read/unread/starred/unstarred ids that to synchronize later. 285 | PROTO-ID is the target protocol feed id. KEY could be :pending-read, 286 | :pending-unread, :pending-starred and :pending-unstarred. IDS is the id list to 287 | append." 288 | (let* ((pending-ids (elfeed-protocol-get-pending-ids proto-id key))) 289 | (dolist (id ids) 290 | (cl-pushnew id pending-ids)) 291 | (elfeed-protocol-set-pending-ids proto-id key pending-ids))) 292 | (defun elfeed-protocol-remove-pending-ids (proto-id key ids) 293 | "Remove pending read/unread/starred/unstarred ids that to synchronize later. 294 | PROTO-ID is the target protocol feed id. KEY could be :pending-read, 295 | :pending-unread, :pending-starred and :pending-unstarred. IDS is the id list to 296 | remove." 297 | (let* ((pending-ids (elfeed-protocol-get-pending-ids proto-id key))) 298 | (dolist (id ids) 299 | (setq pending-ids (delete id pending-ids))) 300 | (elfeed-protocol-set-pending-ids proto-id key pending-ids))) 301 | 302 | (defun elfeed-protocol-clean-pending-ids (proto-id) 303 | "Clean pending read/unread/starred/unstarred entry states. 304 | PROTO-ID is the target protocol feed id." 305 | (elfeed-protocol-set-pending-ids proto-id :pending-read nil) 306 | (elfeed-protocol-set-pending-ids proto-id :pending-unread nil) 307 | (elfeed-protocol-set-pending-ids proto-id :pending-starred nil) 308 | (elfeed-protocol-set-pending-ids proto-id :pending-unstarred nil) 309 | (elfeed-protocol-set-pending-ids proto-id :pending-published nil) 310 | (elfeed-protocol-set-pending-ids proto-id :pending-unpublished nil)) 311 | 312 | (defun elfeed-protocol-generate-ids-str (separate start end) 313 | "Generate article ids string from START id to END id. 314 | SEPARATE is the string to be insert between each id." 315 | (string-trim-right (cl-loop for id from start to end concat (format "%d%s" id separate)) separate)) 316 | 317 | (defun elfeed-protocol-join-ids-to-str (separate &rest ids) 318 | "Convert article ids to string format, for example from (1 2) to \"1,2\". 319 | SEPARATE is the string to be insert between each id, IDS is the target id array." 320 | (string-trim-right (cl-loop for id in ids concat (format "%d%s" id separate)) separate)) 321 | 322 | (defun elfeed-protocol-split-ids-sub-size (separate ids sub-size) 323 | "Convert article ids to sub string list, for example from \"1,2,3\" to (\"1,2\" \"3\") if sub-size is 2. 324 | SEPARATE is the separate string. IDS is the a comma-separated string of item 325 | ids. SUB-SIZE is the item size to split for each request." 326 | (let* ((ids-list (split-string ids separate)) 327 | (size (length ids-list)) 328 | (cycles (max 1 (ceiling (/ (float size) sub-size))))) 329 | (cl-loop for i from 0 to (1- cycles) collect 330 | (string-trim-right 331 | (cl-loop for j from (* i sub-size) to (1- (min size (* (1+ i) sub-size))) concat 332 | (format "%s%s" (elt ids-list j) separate)) separate)))) 333 | 334 | (defun elfeed-protocol-build-entry-groups (entries) 335 | "Split ENTRIES to groups with the same protocol url id." 336 | (let* ((entry-groups (make-hash-table :test 'equal))) 337 | (cl-loop for entry in entries 338 | do (progn 339 | (let ((proto-id (elfeed-protocol-entry-protocol-id entry))) 340 | (when proto-id 341 | (puthash proto-id (append 342 | (gethash proto-id entry-groups) (list entry)) 343 | entry-groups))))) 344 | entry-groups)) 345 | 346 | (defun elfeed-protocol-feed-list () 347 | "Get protocol feed list." 348 | (let* ((feed-url-list (cl-loop for feed in elfeed-protocol-feeds 349 | when (listp feed) collect (car feed) 350 | else collect feed))) 351 | (cl-loop for url in feed-url-list 352 | when (elfeed-protocol-type url) 353 | collect url))) 354 | 355 | (defun elfeed-protocol-normal-feed-list () 356 | "Get normal none protocol feed list." 357 | (let* ((feed-url-list (cl-loop for feed in elfeed-protocol-feeds 358 | when (listp feed) collect (car feed) 359 | else collect feed))) 360 | (cl-loop for url in feed-url-list 361 | unless (elfeed-protocol-type url) collect url))) 362 | 363 | (defun elfeed-protocol-build-meta-author (author) 364 | "Build author meta data for different elfeed version. 365 | Since elfeed 3.2.0, elfeed use :authors instead of :author" 366 | (when author 367 | (if (version< elfeed-version "3.2.0") 368 | (list :author author) 369 | (list :authors (list (list :name author)))))) 370 | 371 | (provide 'elfeed-protocol-common) 372 | 373 | ;;; elfeed-protocol-common.el ends here 374 | -------------------------------------------------------------------------------- /elfeed-protocol-fever.el: -------------------------------------------------------------------------------- 1 | ;;; elfeed-protocol-fever.el --- Fever protocol for elfeed -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | ;; Fever protocol for elfeed. 5 | 6 | (require 'cl-lib) 7 | (require 'json) 8 | (require 'url) 9 | (require 'subr-x) 10 | (require 'elfeed) 11 | (require 'elfeed-protocol-common) 12 | 13 | ;;; Code: 14 | 15 | (defcustom elfeed-protocol-fever-maxsize 50 16 | "Maximize entries size for each request. 17 | Fever API limit a maximum of 50, so set bigger than 50 just invalid." 18 | :group 'elfeed-protocol 19 | :type 'integer) 20 | 21 | (defcustom elfeed-protocol-fever-star-tag 'star 22 | "Default star tag for Fever entry. 23 | If one entry set or remove the tag, 24 | then the starred state in Fever will be synced, too." 25 | :group 'elfeed-protocol 26 | :type 'symbol) 27 | 28 | (defcustom elfeed-protocol-fever-update-unread-only nil 29 | "Determine default update method for Fever. 30 | If t will update unread items only, and if nil will update since last entry 31 | id. For some service that don't provide valid item id like FressRSS, just set to 32 | t as a workaround." 33 | :group 'elfeed-protocol 34 | :type 'boolean) 35 | 36 | (defcustom elfeed-protocol-fever-fetch-category-as-tag t 37 | "If true, tag the Fever feed category to feed item." 38 | :group 'elfeed-protocol 39 | :type 'boolean) 40 | 41 | (defvar elfeed-protocol-fever-categories (make-hash-table :test 'equal) 42 | "Category list from Fever, will be used to tag entries with their Fever category.") 43 | 44 | (defvar elfeed-protocol-fever-feeds (make-hash-table :test 'equal) 45 | "Feed list from Fever, will be filled before updating operation.") 46 | 47 | (defconst elfeed-protocol-fever-api-base "?api") 48 | (defconst elfeed-protocol-fever-api-auth-ok 1) 49 | (defconst elfeed-protocol-fever-api-auth-failed 0) 50 | (defconst elfeed-protocol-fever-api-groups (concat elfeed-protocol-fever-api-base "&groups")) 51 | (defconst elfeed-protocol-fever-api-feeds (concat elfeed-protocol-fever-api-base "&feeds")) 52 | (defconst elfeed-protocol-fever-api-items (concat elfeed-protocol-fever-api-base "&items")) 53 | (defconst elfeed-protocol-fever-api-saved-item-ids (concat elfeed-protocol-fever-api-base "&saved_item_ids")) 54 | (defconst elfeed-protocol-fever-api-unread-item-ids (concat elfeed-protocol-fever-api-base "&unread_item_ids")) 55 | (defconst elfeed-protocol-fever-api-item-state-read "read") 56 | (defconst elfeed-protocol-fever-api-item-state-unread "unread") 57 | (defconst elfeed-protocol-fever-api-item-state-saved "saved") 58 | (defconst elfeed-protocol-fever-api-item-state-unsaved "unsaved") 59 | 60 | (defun elfeed-protocol-fever-id (url) 61 | "Get fever protocol id with URL." 62 | (elfeed-protocol-id "fever" url)) 63 | 64 | (defun elfeed-protocol-fever-entry-p (entry) 65 | "Check if specific ENTRY is fetched from Fever." 66 | (let* ((proto-id (elfeed-protocol-entry-protocol-id entry)) 67 | (proto-type (when proto-id (elfeed-protocol-type proto-id)))) 68 | (string= proto-type "fever"))) 69 | 70 | (defun elfeed-protocol-fever--init-headers () 71 | "Get http request headers for fever." 72 | `(("User-Agent" . ,elfeed-user-agent))) 73 | 74 | (defun elfeed-protocol-fever--get-api-url (host-url) 75 | "Get fever server API url. 76 | HOST-URL is the host name of Fever server." 77 | (let* ((proto-id (elfeed-protocol-fever-id host-url)) 78 | (url (elfeed-protocol-meta-data proto-id :api-url))) 79 | url)) 80 | 81 | (defun elfeed-protocol-fever--build-data (host-url &optional parameter) 82 | "Build data string that sent to Fever server. 83 | HOST-URL is the host name of Fever server. PARAMETER is optional" 84 | (let* ((proto-id (elfeed-protocol-fever-id host-url)) 85 | (user (elfeed-protocol-meta-user proto-id)) 86 | (password (elfeed-protocol-meta-password proto-id)) 87 | (data (concat "api_key=" (md5 (concat user ":" password))))) 88 | (if parameter 89 | (concat data "&" parameter) 90 | data))) 91 | 92 | (defun elfeed-protocol-fever-get-update-mark (proto-id update-action) 93 | "Get last update mark for special UPDATE-ACTION. 94 | PROTO-ID is the target protocol feed id. UPDATE-ACTION could be update or 95 | update-older. If not initialized, just return -1." 96 | (interactive (list (completing-read "Protocol Feed: " (elfeed-protocol-feed-list)) 97 | (intern (completing-read "Update action: " '(update update-older))))) 98 | (let* ((key (cond 99 | ((eq update-action 'update) :last-entry-id) 100 | ((eq update-action 'update-older) :first-entry-id))) 101 | (mark (elfeed-protocol-get-feed-meta-data proto-id key))) 102 | (if mark mark -1))) 103 | 104 | (defun elfeed-protocol-fever-set-update-mark (proto-id update-action mark) 105 | "Set last update mark to elfeed db. 106 | PROTO-ID is the target protocol feed id. UPDATE-ACTION could be update or 107 | update-older. MARK the target value." 108 | (interactive (list (completing-read "Protocol Feed: " (elfeed-protocol-feed-list)) 109 | (intern (completing-read "Update action: " '(update update-older))) 110 | (read-number "Mark number: "))) 111 | (let* ((key (cond 112 | ((eq update-action 'update) :last-entry-id) 113 | ((eq update-action 'update-older) :first-entry-id)))) 114 | (elfeed-protocol-set-feed-meta-data proto-id key mark))) 115 | 116 | (defmacro elfeed-protocol-fever-with-fetch (url method data &rest body) 117 | "Just like `elfeed-with-fetch' but special for fever HTTP request. 118 | URL is the Fever api url to request, METHOD could be \"GET\" or \"POST\", 119 | DATA is the string to send. Optional argument BODY is the rest Lisp code after 120 | operation finished." 121 | (declare (indent defun)) 122 | `(let* ((use-curl elfeed-use-curl) ; capture current value in closure 123 | (headers (elfeed-protocol-fever--init-headers)) 124 | (no-auth-url (elfeed-protocol-no-auth-url ,url)) 125 | (cb (lambda (status) 126 | (if (elfeed-is-status-error status use-curl) 127 | (let ((print-escape-newlines t)) 128 | (elfeed-handle-http-error 129 | no-auth-url 130 | (if use-curl elfeed-curl-error-message status))) 131 | (progn 132 | (unless use-curl 133 | (elfeed-move-to-first-empty-line) 134 | (set-buffer-multibyte t)) 135 | (when elfeed-protocol-log-trace 136 | (elfeed-log 'debug "elfeed-protocol-fever: %s" (buffer-string))) 137 | (elfeed-protocol-fever--parse-result ,@body) 138 | (unless use-curl 139 | (kill-buffer))))))) 140 | (if use-curl 141 | (elfeed-curl-enqueue no-auth-url cb :headers headers 142 | :method ,method :data ,data) 143 | (let ((url-request-extra-headers headers) 144 | (url-request-method ,method) 145 | (url-request-data ,data)) 146 | (url-retrieve no-auth-url cb () t t))))) 147 | 148 | (defmacro elfeed-protocol-fever--parse-result (&rest body) 149 | "Parse fever api result JSON buffer. 150 | Will eval rest BODY expressions at end." 151 | (declare (indent defun)) 152 | `(let* ((result (json-read)) 153 | (api-auth (map-elt result 'auth))) 154 | (if (eq api-auth elfeed-protocol-fever-api-auth-failed) 155 | (elfeed-log 'error "elfeed-protocol-fever: authentication failed, wrong username or password") 156 | ,@body))) 157 | 158 | (defmacro elfeed-protocol-fever-fetch-prepare (host-url &rest body) 159 | "Ensure logged in and feed list updated before expressions. 160 | HOST-URL is the host name of Fever server. And will eval rest 161 | BODY expressions at end." 162 | (declare (indent defun)) 163 | `(elfeed-protocol-fever--update-feed-list 164 | ,host-url (lambda () ,@body))) 165 | 166 | (defun elfeed-protocol-fever--update-categories-list (host-url &optional callback) 167 | "Update Fever server categories list. 168 | HOST-URL is the host name of Fever server. Will call CALLBACK at end." 169 | (elfeed-log 'debug "elfeed-protocol-fever: update category list") 170 | (let* ((url (concat (elfeed-protocol-fever--get-api-url host-url) 171 | elfeed-protocol-fever-api-groups)) 172 | (data (elfeed-protocol-fever--build-data host-url))) 173 | (elfeed-protocol-fever-with-fetch 174 | url "POST" data 175 | (elfeed-protocol-fever--parse-categories host-url result) 176 | (when callback (funcall callback))))) 177 | 178 | (defun elfeed-protocol-fever--parse-categories (host-url content) 179 | "Parse the feeds JSON buffer and cache the result. 180 | HOST-URL is the host name of Fever server. CONTENT is the result JSON content 181 | by http request. Return cached `elfeed-protocol-fever-categories'." 182 | (let* ((proto-id (elfeed-protocol-fever-id host-url)) 183 | (categories (map-elt content 'groups))) 184 | (puthash proto-id categories elfeed-protocol-fever-categories) 185 | elfeed-protocol-fever-categories)) 186 | 187 | (defun elfeed-protocol-fever--get-category-name (host-url category-id) 188 | "Return category name from HOST-URL for CATEGORY-ID." 189 | (let* ((proto-id (elfeed-protocol-fever-id host-url)) 190 | (categories (gethash proto-id elfeed-protocol-fever-categories)) 191 | (category (catch 'found 192 | (let* ((length (length categories))) 193 | (dotimes (i length) 194 | (let* ((item (elt categories i)) 195 | (id (map-elt item 'id)) 196 | (title (map-elt item 'title))) 197 | (when (eq id category-id) 198 | (throw 'found title)))))))) 199 | category)) 200 | 201 | (defun elfeed-protocol-fever--update-feed-list (host-url &optional callback) 202 | "Update Fever server feeds list. 203 | HOST-URL is the host name of Fever server. Will call CALLBACK 204 | at end." 205 | (elfeed-log 'debug "elfeed-protocol-fever: update feed list") 206 | (let* ((url (concat (elfeed-protocol-fever--get-api-url host-url) 207 | elfeed-protocol-fever-api-feeds)) 208 | (data (elfeed-protocol-fever--build-data host-url)) 209 | (parse-feeds-func (lambda () 210 | (elfeed-protocol-fever-with-fetch 211 | url "POST" data 212 | (elfeed-protocol-fever--parse-feeds host-url result) 213 | (when callback (funcall callback)))))) 214 | (if elfeed-protocol-fever-fetch-category-as-tag 215 | (elfeed-protocol-fever--update-categories-list host-url parse-feeds-func) 216 | (funcall parse-feeds-func)))) 217 | 218 | (defun elfeed-protocol-fever--parse-feeds (host-url content) 219 | "Parse the feeds JSON buffer and fill results to db. 220 | HOST-URL is the host name of Fever server. CONTENT is the result JSON content by 221 | http request. Return `elfeed-protocol-fever-feeds'." 222 | (let* ((proto-id (elfeed-protocol-fever-id host-url)) 223 | (feeds (map-elt content 'feeds)) 224 | (feeds_groups (map-elt content 'feeds_groups)) 225 | (get-group-id-func (lambda (feed-id) 226 | (catch 'found 227 | (let* ((length (length feeds_groups))) 228 | (dotimes (i length) 229 | (let* ((item (elt feeds_groups i)) 230 | (group-id (map-elt item 'group_id)) 231 | (feed-ids (split-string (map-elt item 'feed_ids) ","))) 232 | (when (member (number-to-string feed-id) feed-ids) 233 | (throw 'found group-id))))))))) 234 | (dotimes (i (length feeds)) 235 | (let* ((feed (elt feeds i)) 236 | (feed-url (map-elt feed 'url)) 237 | (feed-meta-id (map-elt feed 'id)) 238 | (feed-id (elfeed-protocol-format-subfeed-id 239 | proto-id feed-url)) 240 | (feed-title (elfeed-cleanup (map-elt feed 'title))) 241 | (feed-db (elfeed-db-get-feed feed-id))) 242 | (setf (elfeed-feed-url feed-db) feed-id 243 | (elfeed-feed-title feed-db) feed-title) 244 | ;; fill group id to each feed 245 | (when elfeed-protocol-fever-fetch-category-as-tag 246 | (setf (alist-get 'group_id (elt feeds i)) (funcall get-group-id-func feed-meta-id))))) 247 | (puthash proto-id feeds elfeed-protocol-fever-feeds) 248 | (elfeed-log 'debug "elfeed-protocol-fever: found %s feeds" (length feeds)) 249 | elfeed-protocol-fever-feeds)) 250 | 251 | (defun elfeed-protocol-fever--get-subfeed-url (host-url feed-id) 252 | "Get sub feed url for the fever protocol feed HOST-URL and FEED-ID." 253 | (let* ((url (catch 'found 254 | (let* ((proto-id (elfeed-protocol-fever-id host-url)) 255 | (feeds (gethash proto-id elfeed-protocol-fever-feeds)) 256 | (length (length feeds))) 257 | (dotimes (i length) 258 | (let* ((feed (elt feeds i)) 259 | (id (map-elt feed 'id)) 260 | (url (map-elt feed 'url))) 261 | (when (eq id feed-id) 262 | (throw 'found url)))))))) 263 | (unless url 264 | (setq url elfeed-protocol-unknown-feed-url) 265 | (elfeed-log 'warn "elfeed-protocol-fever: no subfeed for feed id %s, fallback to unknown feed" feed-id)) 266 | url)) 267 | 268 | (defun elfeed-protocol-fever--get-subfeed-id (host-url feed-url) 269 | "Get sub feed id the for fever protocol feed HOST-URL and FEED-URL." 270 | (let* ((id (catch 'found 271 | (let* ((proto-id (elfeed-protocol-fever-id host-url)) 272 | (feeds (gethash proto-id elfeed-protocol-fever-feeds)) 273 | (length (length feeds))) 274 | (dotimes (i length) 275 | (let* ((feed (elt feeds i)) 276 | (id (map-elt feed 'id)) 277 | (url (map-elt feed 'url))) 278 | (when (string= url feed-url) 279 | (throw 'found id)))))))) 280 | (unless id 281 | (elfeed-log 'error "elfeed-protocol-fever: no subfeed for feed url %s" feed-url)) 282 | id)) 283 | 284 | (defun elfeed-protocol-fever--get-subfeed-category-id (host-url feed-id) 285 | "Get sub feed category id for the ttrss protocol feed HOST-URL and FEED-ID." 286 | (let* ((group-id (catch 'found 287 | (let* ((proto-id (elfeed-protocol-fever-id host-url)) 288 | (feeds (gethash proto-id elfeed-protocol-fever-feeds)) 289 | (length (length feeds))) 290 | (dotimes (i length) 291 | (let* ((feed (elt feeds i)) 292 | (id (map-elt feed 'id)) 293 | (group-id (map-elt feed 'group_id))) 294 | (when (eq id feed-id) 295 | (throw 'found group-id)))))))) 296 | group-id)) 297 | 298 | (defun elfeed-protocol-fever--get-entries (host-url ids &optional mark-state update-action callback) 299 | "Get entries from Fever server. 300 | HOST-URL is the host name of Fever server. IDS is the a comma-separated string 301 | of item ids to request. MARK-STATE UPDATE-ACTION CALLBACK will send to 302 | `elfeed-protocol-fever--parse-entries'." 303 | (let* ((url (concat (elfeed-protocol-fever--get-api-url host-url) 304 | elfeed-protocol-fever-api-items)) 305 | (data (elfeed-protocol-fever--build-data host-url)) 306 | (split-ids (elfeed-protocol-split-ids-sub-size 307 | "," ids elfeed-protocol-fever-maxsize))) 308 | (cl-loop for sub-ids in split-ids do 309 | (elfeed-log 'debug "elfeed-protocol-fever: get entries %s" sub-ids) 310 | (elfeed-protocol-fever-with-fetch 311 | (concat url "&with_ids=" sub-ids) "POST" data 312 | (elfeed-protocol-fever--parse-entries host-url (map-elt result 'items) mark-state update-action callback) 313 | (run-hook-with-args 'elfeed-update-hooks host-url))))) 314 | 315 | (defun elfeed-protocol-fever--parse-entries (host-url items &optional mark-state update-action callback) 316 | "Parse the entries JSON buffer and fill results to elfeed db. 317 | HOST-URL is the host name of Fever server. ITEMS is the result JSON items by 318 | http request. If MARK-STATE is nil, then just not update :last-entry-id or 319 | :first-entry-id values. UPDATE-ACTION could be update, update-older or 320 | update-star. If CALLBACK is not nil, will call it with the result entries as 321 | argument. Return parsed entries." 322 | (if (> (hash-table-count elfeed-protocol-fever-feeds) 0) 323 | (let* ((proto-id (elfeed-protocol-fever-id host-url)) 324 | (entry-mark (elfeed-protocol-fever-get-update-mark proto-id update-action)) 325 | (min-entry-id -1) 326 | (max-entry-id -1) 327 | (first-entry-id -1) 328 | (unread-num 0) 329 | (starred-num 0) 330 | (begin-time (time-to-seconds)) 331 | entries) 332 | (elfeed-log 'debug "elfeed-protocol-fever: %s, parsing entries, entry-mark: %d" update-action entry-mark) 333 | (setq entries 334 | (cl-loop for item across items collect 335 | (pcase-let* (((map id ('url entry-url) title 336 | author ('created_on_time pub-date) ('html body) 337 | ('feed_id feed-id)) 338 | item) 339 | (id (if (stringp id) (string-to-number id) id)) 340 | (feed-id (if (stringp feed-id) (string-to-number feed-id) feed-id)) 341 | (guid-hash (elfeed-generate-id (format "%s%s%s%s" title entry-url pub-date body))) 342 | (feed-url 343 | (if (null feed-id) 344 | "" 345 | (elfeed-protocol-fever--get-subfeed-url host-url feed-id))) 346 | (unread (eq (map-elt item 'is_read) 0)) 347 | (starred (eq (map-elt item 'is_saved) 1)) 348 | 349 | (namespace (elfeed-url-to-namespace feed-url)) 350 | (full-id (cons namespace (elfeed-cleanup guid-hash))) 351 | (original (elfeed-db-get-entry full-id)) 352 | (original-date (and original 353 | (elfeed-entry-date original))) 354 | (category-name (when elfeed-protocol-fever-fetch-category-as-tag 355 | (elfeed-protocol-fever--get-category-name 356 | host-url 357 | (elfeed-protocol-fever--get-subfeed-category-id host-url feed-id)))) 358 | (autotags (elfeed-protocol-feed-autotags proto-id feed-url)) 359 | (fixtags (elfeed-normalize-tags 360 | autotags elfeed-initial-tags)) 361 | (tags (progn 362 | (unless unread 363 | (setq fixtags (delete 'unread fixtags))) 364 | (when starred 365 | (push elfeed-protocol-fever-star-tag fixtags)) 366 | (when category-name 367 | (push (intern category-name) fixtags)) 368 | fixtags)) 369 | (db-entry (elfeed-entry--create 370 | :title (elfeed-cleanup title) 371 | :id full-id 372 | :feed-id (elfeed-protocol-format-subfeed-id 373 | proto-id feed-url) 374 | :link (elfeed-cleanup entry-url) 375 | :tags tags 376 | :date (elfeed-new-date-for-entry 377 | original-date pub-date) 378 | :content body 379 | :content-type 'html 380 | :meta `(,@(elfeed-protocol-build-meta-author author) 381 | ,@(list :protocol-id proto-id 382 | :id id 383 | :guid-hash guid-hash 384 | :feed-id feed-id))))) 385 | (when unread (setq unread-num (1+ unread-num))) 386 | (when starred (setq starred-num (1+ starred-num))) 387 | 388 | ;; force override unread and star tags without repeat sync operation 389 | (when original 390 | (if unread (elfeed-tag-1 original 'unread) 391 | (elfeed-untag-1 original 'unread)) 392 | (if starred (elfeed-tag-1 original elfeed-protocol-fever-star-tag) 393 | (elfeed-untag-1 original elfeed-protocol-fever-star-tag))) 394 | 395 | (when (> id max-entry-id) 396 | (setq max-entry-id id)) 397 | (if (< min-entry-id 0) 398 | (setq min-entry-id id) 399 | (when (< id min-entry-id) 400 | (setq min-entry-id id))) 401 | 402 | (dolist (hook elfeed-new-entry-parse-hook) 403 | (run-hook-with-args hook :fever item db-entry)) 404 | db-entry))) 405 | (elfeed-db-add entries) 406 | (when callback (funcall callback entries)) 407 | 408 | ;; update last entry skip count 409 | (when mark-state 410 | (if (>= entry-mark 0) 411 | ;; update entry mark 412 | (cond 413 | ((eq update-action 'update) 414 | (elfeed-protocol-fever-set-update-mark 415 | proto-id update-action (max entry-mark max-entry-id))) 416 | ((eq update-action 'update-older) 417 | (let* ((id (max 1 (- entry-mark elfeed-protocol-fever-maxsize)))) 418 | (elfeed-protocol-fever-set-update-mark 419 | proto-id update-action id)))) 420 | ;; init entry mark 421 | (setq first-entry-id (max 1 max-entry-id)) 422 | (cond 423 | ((eq update-action 'update) 424 | (elfeed-protocol-fever-set-update-mark proto-id update-action first-entry-id) 425 | ;; set :first-entry-id same with :last-entry-id 426 | (elfeed-protocol-fever-set-update-mark proto-id 'update-older first-entry-id)) 427 | ((eq update-action 'update-older) 428 | (elfeed-protocol-fever-set-update-mark proto-id update-action first-entry-id))))) 429 | 430 | (elfeed-log 'debug "elfeed-protocol-fever: %s, parsed %d entries(%d unread, %d starred, min-entry-id %d, max-entry-id %d) with %fs, entry-mark: %d" 431 | update-action (length entries) unread-num starred-num min-entry-id max-entry-id 432 | (- (time-to-seconds) begin-time) 433 | (elfeed-protocol-fever-get-update-mark proto-id update-action)) 434 | entries) 435 | (progn 436 | (elfeed-log 'error "elfeed-protocol-fever: elfeed-protocol-fever-feeds is nil, please call elfeed-protocol-fever--update-feed-list first") 437 | nil))) 438 | 439 | (defun elfeed-protocol-fever--do-update (host-url action &optional arg callback) 440 | "Real fever protocol updating operations. 441 | HOST-URL is the host name of Fever server, and user field authentication info is 442 | always required so could find the related protocol feed id correctly, for 443 | example \"https://user:pass@myhost.com\". ACTION could be init, update, 444 | update-older and update-star. For init, will fetch unread, starred and latest 445 | entries. For update and update-older, will fetch entries with article ids, the 446 | ARG is the ids. For update-unread, will fetch all unread entries. For 447 | update-star, will fetch all starred entries. If CALLBACK is not nil, will call 448 | it with the result entries as argument." 449 | (elfeed-log 'debug "elfeed-protocol-fever: update entries with action %s, arg %s" action arg) 450 | (let* ((proto-id (elfeed-protocol-fever-id host-url)) 451 | (url-starred (concat (elfeed-protocol-fever--get-api-url host-url) 452 | elfeed-protocol-fever-api-saved-item-ids)) 453 | (url-unread (concat (elfeed-protocol-fever--get-api-url host-url) 454 | elfeed-protocol-fever-api-unread-item-ids)) 455 | (data (elfeed-protocol-fever--build-data host-url))) 456 | (unless elfeed--inhibit-update-init-hooks 457 | (run-hooks 'elfeed-update-init-hooks)) 458 | (cond 459 | ;; initial sync, fetch starred and unread entries 460 | ((eq action 'init) 461 | (elfeed-protocol-fever-set-update-mark proto-id 'update -1) 462 | (elfeed-protocol-fever-set-update-mark proto-id 'update-older -1) 463 | (elfeed-protocol-clean-pending-ids proto-id) 464 | (elfeed-protocol-fever-with-fetch 465 | url-starred "POST" data 466 | (elfeed-protocol-fever--get-entries host-url (map-elt result 'saved_item_ids) nil 'update-star callback) 467 | (elfeed-protocol-fever-with-fetch 468 | url-unread "POST" data 469 | (elfeed-protocol-fever--get-entries host-url (map-elt result 'unread_item_ids) t 'update callback)))) 470 | ;; update older or latest entries 471 | ((or (eq action 'update) (eq action 'update-older)) 472 | (elfeed-protocol-fever--get-entries host-url arg t action callback)) 473 | ;; update unread entries 474 | ((eq action 'update-unread) 475 | (elfeed-protocol-fever-with-fetch 476 | url-unread "POST" data 477 | (elfeed-protocol-fever--get-entries host-url (map-elt result 'unread_item_ids) nil action callback))) 478 | ;; update starred entries 479 | ((eq action 'update-star) 480 | (elfeed-protocol-fever-with-fetch 481 | url-starred "POST" data 482 | (elfeed-protocol-fever--get-entries host-url (map-elt result 'saved_item_ids) nil action callback)))))) 483 | 484 | (defun elfeed-protocol-fever-reinit (host-url) 485 | "Retry initial sync operation. 486 | Will fetch starred and unread entries from Fever server. 487 | HOST-URL is the host name of Fever server." 488 | (interactive (list (elfeed-protocol-url 489 | (completing-read "Protocol Feed: " (elfeed-protocol-feed-list))))) 490 | (elfeed-protocol-fever-fetch-prepare 491 | host-url 492 | (elfeed-protocol-fever--do-update host-url 'init))) 493 | 494 | (defun elfeed-protocol-fever-update-older (host-url) 495 | "Fetch older entries. 496 | HOST-URL is the host name of Fever server." 497 | (interactive (list (elfeed-protocol-url 498 | (completing-read "Protocol Feed: " (elfeed-protocol-feed-list))))) 499 | (let* ((proto-id (elfeed-protocol-fever-id host-url)) 500 | (first-entry-id (elfeed-protocol-fever-get-update-mark proto-id 'update-older)) 501 | (ids (elfeed-protocol-generate-ids-str "," 502 | (max 1 (- first-entry-id elfeed-protocol-fever-maxsize)) 503 | (max 1 (- first-entry-id 1))))) 504 | (elfeed-protocol-fever-fetch-prepare 505 | host-url 506 | (elfeed-protocol-fever--do-update host-url 'update-older ids)))) 507 | 508 | (defun elfeed-protocol-fever-update-star (host-url) 509 | "Fetch all starred entries. 510 | HOST-URL is the host name of Fever server." 511 | (interactive (list (elfeed-protocol-url 512 | (completing-read "Protocol Feed: " (elfeed-protocol-feed-list))))) 513 | (elfeed-protocol-fever-fetch-prepare 514 | host-url 515 | (elfeed-protocol-fever--do-update host-url 'update-star))) 516 | 517 | (defun elfeed-protocol-fever--write-item (host-url id state) 518 | "Notify item to be read/unread/starred/unstarred. 519 | HOST-URL is the host name of Fever server. ID is the target entry id. 520 | STATE could be \"read\", \"unread\", \"saved\" and \"unsaved\"." 521 | (let* ((url (elfeed-protocol-fever--get-api-url host-url)) 522 | (data (elfeed-protocol-fever--build-data 523 | host-url (format "mark=item&id=%s&as=%s" id state)))) 524 | (elfeed-log 'debug "elfeed-protocol-fever: mark item %s as %s" id state) 525 | (elfeed-protocol-fever-with-fetch 526 | url "POST" data))) 527 | 528 | (defun elfeed-protocol-fever-mark-read (host-url id) 529 | "Notify item to be read. 530 | HOST-URL is the host name of Fever server. ID is the target entry id." 531 | (elfeed-protocol-fever--write-item 532 | host-url id elfeed-protocol-fever-api-item-state-read)) 533 | 534 | (defun elfeed-protocol-fever-mark-unread (host-url id) 535 | "Notify item to be unread. 536 | HOST-URL is the host name of Fever server. ID is the target entry id." 537 | (elfeed-protocol-fever--write-item 538 | host-url id elfeed-protocol-fever-api-item-state-unread)) 539 | 540 | (defun elfeed-protocol-fever-mark-starred (host-url id) 541 | "Notify item to be starred. 542 | HOST-URL is the host name of Fever server. ID is the target entry id." 543 | (elfeed-protocol-fever--write-item 544 | host-url id elfeed-protocol-fever-api-item-state-saved)) 545 | 546 | (defun elfeed-protocol-fever-mark-unstarred (host-url id) 547 | "Notify item to be unstarred. 548 | HOST-URL is the host name of Fever server. ID is the target entry id." 549 | (elfeed-protocol-fever--write-item 550 | host-url id elfeed-protocol-fever-api-item-state-unsaved)) 551 | 552 | (defun elfeed-protocol-fever-sync-pending-ids (host-url) 553 | "Sync pending read/unread/starred/unstarred entry states to Fever server. 554 | HOST-URL is the host name of Fever server." 555 | (let* ((proto-id (elfeed-protocol-fever-id host-url)) 556 | (pending-read-ids (elfeed-protocol-get-pending-ids proto-id :pending-read)) 557 | (pending-unread-ids (elfeed-protocol-get-pending-ids proto-id :pending-unread)) 558 | (pending-starred-ids (elfeed-protocol-get-pending-ids proto-id :pending-starred)) 559 | (pending-unstarred-ids (elfeed-protocol-get-pending-ids proto-id :pending-unstarred))) 560 | (dolist (id pending-read-ids) (elfeed-protocol-fever-mark-read host-url id)) 561 | (dolist (id pending-unread-ids) (elfeed-protocol-fever-mark-unread host-url id)) 562 | (dolist (id pending-starred-ids) (elfeed-protocol-fever-mark-starred host-url id)) 563 | (dolist (id pending-unstarred-ids) (elfeed-protocol-fever-mark-unstarred host-url id)) 564 | (elfeed-protocol-clean-pending-ids proto-id))) 565 | 566 | (defun elfeed-protocol-fever-append-pending-id (host-url entry tag action) 567 | "Append read/unread/starred/unstarred ids to pending list. 568 | HOST-URL is the host name of Fever server. ENTRY is the target entry object. 569 | TAG is the action tag, for example unread and `elfeed-protocol-fever-star-tag', 570 | ACTION could be add or remove." 571 | (when (elfeed-protocol-fever-entry-p entry) 572 | (let* ((proto-id (elfeed-protocol-fever-id host-url)) 573 | (id (elfeed-meta entry :id))) 574 | (cond 575 | ((eq action 'add) 576 | (cond 577 | ((eq tag 'unread) 578 | (elfeed-protocol-append-pending-ids proto-id :pending-unread (list id)) 579 | (elfeed-protocol-remove-pending-ids proto-id :pending-read (list id))) 580 | ((eq tag elfeed-protocol-fever-star-tag) 581 | (elfeed-protocol-append-pending-ids proto-id :pending-starred (list id)) 582 | (elfeed-protocol-remove-pending-ids proto-id :pending-unstarred (list id))))) 583 | ((eq action 'remove) 584 | (cond 585 | ((eq tag 'unread) 586 | (elfeed-protocol-append-pending-ids proto-id :pending-read (list id)) 587 | (elfeed-protocol-remove-pending-ids proto-id :pending-unread (list id))) 588 | ((eq tag elfeed-protocol-fever-star-tag) 589 | (elfeed-protocol-append-pending-ids proto-id :pending-unstarred (list id)) 590 | (elfeed-protocol-remove-pending-ids proto-id :pending-starred (list id))))))))) 591 | 592 | (defun elfeed-protocol-fever-pre-tag (host-url entries &rest tags) 593 | "Sync unread and starred states before tags added. 594 | HOST-URL is the host name of Fever server. ENTRIES is the 595 | target entry objects. TAGS is the tags are adding now." 596 | (dolist (tag tags) 597 | (cl-loop for entry in entries 598 | unless (elfeed-tagged-p tag entry) 599 | do (elfeed-protocol-fever-append-pending-id host-url entry tag 'add))) 600 | (unless elfeed-protocol-lazy-sync 601 | (elfeed-protocol-fever-sync-pending-ids host-url))) 602 | 603 | (defun elfeed-protocol-fever-pre-untag (host-url entries &rest tags) 604 | "Sync unread and starred states before tags removed. 605 | HOST-URL is the host name of Fever server. ENTRIES is the 606 | target entry objects. TAGS is the tags are removing now." 607 | (dolist (tag tags) 608 | (cl-loop for entry in entries 609 | when (elfeed-tagged-p tag entry) 610 | collect (elfeed-protocol-fever-append-pending-id host-url entry tag 'remove))) 611 | (unless elfeed-protocol-lazy-sync 612 | (elfeed-protocol-fever-sync-pending-ids host-url))) 613 | 614 | (defun elfeed-protocol-fever-update (host-or-subfeed-url &optional callback) 615 | "Fever protocol updater. 616 | HOST-OR-SUBFEED-URL could be the host name of Fever server, and user field 617 | authentication info is always required so could find the related protocol feed 618 | id correctly, for example \"https://user@myhost.com\". And HOST-OR-SUBFEED-URL 619 | also could be the sub feed url, too, for example 620 | \"https://user@myhost.com::https://subfeed.com\". If first time run, it will 621 | initial sync operation, or will only fetch the updated entries since last 622 | modified. if CALLBACK is not nil will call it with the result entries as 623 | argument" 624 | (interactive (list (elfeed-protocol-url 625 | (completing-read "Protocol Feed: " (elfeed-protocol-feed-list))))) 626 | (let* ((host-url (elfeed-protocol-host-url host-or-subfeed-url)) 627 | (proto-id (elfeed-protocol-fever-id host-url)) 628 | (last-entry-id (elfeed-protocol-fever-get-update-mark proto-id 'update)) 629 | (ids (elfeed-protocol-generate-ids-str 630 | "," 631 | (1+ last-entry-id) 632 | (+ last-entry-id elfeed-protocol-fever-maxsize)))) 633 | (elfeed-protocol-add-unknown-feed proto-id) ; add unknown feed for fallback 634 | (elfeed-protocol-fever-sync-pending-ids host-url) 635 | (elfeed-protocol-fever-fetch-prepare 636 | host-url 637 | (if (>= last-entry-id 0) 638 | (if elfeed-protocol-fever-update-unread-only 639 | (elfeed-protocol-fever--do-update host-url 'update-unread nil callback) 640 | (elfeed-protocol-fever--do-update host-url 'update ids callback)) 641 | (elfeed-protocol-fever--do-update host-url 'init nil callback))))) 642 | 643 | (provide 'elfeed-protocol-fever) 644 | 645 | ;;; elfeed-protocol-fever.el ends here 646 | -------------------------------------------------------------------------------- /elfeed-protocol-newsblur.el: -------------------------------------------------------------------------------- 1 | ;;; elfeed-protocol-newsblur.el --- NewsBlur protocol for elfeed -*- lexical-binding: t; -*- 2 | 3 | ;;; Commentary: 4 | ;; NewsBlur protocol for elfeed. 5 | 6 | (require 'cl-lib) 7 | (require 'json) 8 | (require 'url) 9 | (require 'subr-x) 10 | (require 'elfeed) 11 | (require 'elfeed-protocol-common) 12 | 13 | ;;; Code: 14 | 15 | (defcustom elfeed-protocol-newsblur-maxpages 20 16 | "Maximize page size for each request." 17 | :group 'elfeed-protocol 18 | :type 'integer) 19 | 20 | (defcustom elfeed-protocol-newsblur-star-tag 'star 21 | "Default star tag for NewsBlur entry. 22 | If one entry set or remove the tag, 23 | then the starred state in NewsBlur will be synced, too." 24 | :group 'elfeed-protocol 25 | :type 'symbol) 26 | 27 | (defcustom elfeed-protocol-newsblur-fetch-tags t 28 | "Determine if fetch entry tags from NewsBlur." 29 | :group 'elfeed-protocol 30 | :type 'boolean) 31 | 32 | (defcustom elfeed-protocol-newsblur-fetch-category-as-tag t 33 | "If true, tag the NewsBlur feed category to feed item." 34 | :group 'elfeed-protocol 35 | :type 'boolean) 36 | 37 | (defcustom elfeed-protocol-newsblur-sub-category-separator "/" 38 | "The separator for NewsBlur sub feed category name." 39 | :group 'elfeed-protocol 40 | :type 'string) 41 | 42 | (defvar elfeed-protocol-newsblur-categories (make-hash-table :test 'equal) 43 | "Category list from NewsBlur, will be used to tag entries with their NewsBlur category.") 44 | 45 | (defvar elfeed-protocol-newsblur-feeds (make-hash-table :test 'equal) 46 | "Feed list from NewsBlur, will be filled before updating operation.") 47 | 48 | (defconst elfeed-protocol-newsblur-api-login "/api/login") 49 | (defconst elfeed-protocol-newsblur-api-reader-feeds "/reader/feeds") 50 | (defconst elfeed-protocol-newsblur-api-reader-river-stories "/reader/river_stories?include_story_content=true&read_filter=unread&order=newest&include_hidden=true&page=%s") 51 | (defconst elfeed-protocol-newsblur-api-reader-feed "/reader/feed/%s??include_story_content=true&read_filter=all&order=newest&include_hidden=true&page=%s") 52 | (defconst elfeed-protocol-newsblur-api-reader-starred-stories "/reader/starred_stories?page=%s") 53 | (defconst elfeed-protocol-newsblur-api-reader-mark-story-read "/reader/mark_story_hashes_as_read") 54 | (defconst elfeed-protocol-newsblur-api-reader-mark-story-unread "/reader/mark_story_hash_as_unread") 55 | (defconst elfeed-protocol-newsblur-api-reader-mark-story-starred "/reader/mark_story_hash_as_starred") 56 | (defconst elfeed-protocol-newsblur-api-reader-mark-story-unstarred "/reader/mark_story_hash_as_unstarred") 57 | 58 | (defun elfeed-protocol-newsblur-id (url) 59 | "Get newsblur protocol id with URL." 60 | (elfeed-protocol-id "newsblur" url)) 61 | 62 | (defmacro elfeed-protocol-newsblur-with-fetch (url method data &rest body) 63 | "Just like `elfeed-with-fetch' but special for NewsBlur HTTP request. 64 | URL is the target url to request, METHOD could be \"GET\" or \"POST\", 65 | DATA is in JSON string format. Optional argument BODY is the rest 66 | Lisp code after operation finished." 67 | (declare (indent defun)) 68 | `(let* ((use-curl elfeed-use-curl) ; capture current value in closure 69 | (headers `(("User-Agent" . ,elfeed-user-agent))) 70 | (no-auth-url (elfeed-protocol-no-auth-url ,url)) 71 | (cb (lambda (status) 72 | (if (elfeed-is-status-error status use-curl) 73 | (let ((print-escape-newlines t)) 74 | (elfeed-handle-http-error 75 | no-auth-url 76 | (if use-curl elfeed-curl-error-message status))) 77 | (progn 78 | (unless use-curl 79 | (elfeed-move-to-first-empty-line) 80 | (set-buffer-multibyte t)) 81 | (when elfeed-protocol-log-trace 82 | (elfeed-log 'debug "elfeed-protocol-newsblur: %s" (buffer-string))) 83 | (elfeed-protocol-newsblur--parse-result ,@body) 84 | (unless use-curl 85 | (kill-buffer))))))) 86 | (if use-curl 87 | (elfeed-curl-enqueue no-auth-url cb :headers headers 88 | :method ,method :data ,data) 89 | (let ((url-request-extra-headers headers) 90 | (url-request-method ,method) 91 | (url-request-data ,data)) 92 | (url-retrieve no-auth-url cb () t t))))) 93 | 94 | (defmacro elfeed-protocol-newsblur--parse-result (&rest body) 95 | "Parse newsblur api result JSON buffer. 96 | Will eval rest BODY expressions at end." 97 | (declare (indent defun)) 98 | `(let* ((result (json-read)) 99 | (errors (map-elt result 'errors))) 100 | (if errors 101 | (elfeed-log 'error "elfeed-protocol-newsblur: %s" errors) 102 | ,@body))) 103 | 104 | (defmacro elfeed-protocol-newsblur-fetch-prepare (host-url &rest body) 105 | "Ensure logged in and feed list updated before expressions. 106 | HOST-URL is the host name of NewsBlur server. And will eval rest 107 | BODY expressions after login." 108 | (declare (indent defun)) 109 | `(elfeed-protocol-newsblur--update-feed-list 110 | ,host-url 111 | (lambda (need-login) 112 | (if need-login 113 | (elfeed-protocol-newsblur--login 114 | ,host-url 115 | (lambda () 116 | (elfeed-protocol-newsblur--update-feed-list 117 | ,host-url 118 | (lambda (need-login) 119 | (if need-login 120 | (elfeed-log 'error "elfeed-protocol-newsblur: login failed, ensure setup cookie for curl like this (setq elfeed-curl-extra-arguments '(\"-c\" \"/tmp/newsblur-cookie\" \"-b\" \"/tmp/newsblur-cookie\"))") 121 | ,@body))))) 122 | ,@body)))) 123 | 124 | (defun elfeed-protocol-newsblur--login (host-url &optional callback) 125 | "Login remote NewsBlur server. 126 | HOST-URL is the host name of NewsBlur server. Will call CALLBACK 127 | after login." 128 | (elfeed-log 'debug "elfeed-protocol-newsblur: login") 129 | (let* ((proto-id (elfeed-protocol-newsblur-id host-url)) 130 | (user (elfeed-protocol-meta-user proto-id)) 131 | (password (elfeed-protocol-meta-password proto-id)) 132 | (url (concat host-url elfeed-protocol-newsblur-api-login)) 133 | (data (format "username=%s&password=%s" user password))) 134 | (elfeed-protocol-newsblur-with-fetch 135 | url "POST" data 136 | (when callback (funcall callback))))) 137 | 138 | (defun elfeed-protocol-newsblur--parse-categories (host-url content) 139 | "Parse the feeds JSON buffer and cache the result. 140 | HOST-URL is the host name of NewsBlur server. CONTENT is the result JSON content 141 | by http request. Return cached `elfeed-protocol-newsblur-categories'." 142 | (elfeed-log 'debug "elfeed-protocol-newsblur: parsing categories") 143 | (let* ((proto-id (elfeed-protocol-newsblur-id host-url)) 144 | (categories (map-elt content 'folders))) 145 | (puthash proto-id categories elfeed-protocol-newsblur-categories) 146 | elfeed-protocol-newsblur-categories)) 147 | 148 | (defun elfeed-protocol-newsblur--get-category-name (host-url feed-id) 149 | "Return category name from HOST-URL for FEED-ID." 150 | (let* ((proto-id (elfeed-protocol-newsblur-id host-url)) 151 | (categories (gethash proto-id elfeed-protocol-newsblur-categories)) 152 | (category (catch 'found 153 | (let* ((length (length categories))) 154 | (dotimes (i length) 155 | (let* ((item (elt categories i)) 156 | (name (elfeed-protocol-newsblur--do-get-category-name item feed-id))) 157 | (when name 158 | (throw 'found name)))))))) 159 | category)) 160 | 161 | (defun elfeed-protocol-newsblur--do-get-category-name (category feed-id &optional prefix) 162 | "Return category name from HOST-URL for FEED-ID." 163 | ;; ignore feed that do not have category 164 | (when (listp category) 165 | (let* ((name (symbol-name (caar category))) 166 | (content (cdar category)) 167 | (category (catch 'found 168 | (dotimes (i (length content)) 169 | (let* ((item (elt content i)) 170 | (new-prefix (if prefix 171 | (concat 172 | prefix elfeed-protocol-newsblur-sub-category-separator name) 173 | name))) 174 | (if (listp item) 175 | ;; sub category 176 | (let* ((name (elfeed-protocol-newsblur--do-get-category-name 177 | item feed-id new-prefix))) 178 | (when name 179 | (throw 'found name))) 180 | ;; query feed ids 181 | (when (eq item feed-id) 182 | (throw 'found new-prefix)))))))) 183 | category))) 184 | 185 | (defun elfeed-protocol-newsblur--update-feed-list (host-url &optional callback) 186 | "Update NewsBlur server feeds list. 187 | HOST-URL is the host name of NewsBlur server. Will call CALLBACK at 188 | end with argument NEED-LOGIN." 189 | (elfeed-log 'debug "elfeed-protocol-newsblur: update feed list") 190 | (let* ((url (concat host-url elfeed-protocol-newsblur-api-reader-feeds)) 191 | (data "include_favicons=false")) 192 | (elfeed-protocol-newsblur-with-fetch 193 | url "GET" data 194 | (let* ((authenticated (map-elt result 'authenticated)) 195 | (need-login (eq authenticated ':json-false))) 196 | (unless need-login 197 | (when elfeed-protocol-newsblur-fetch-category-as-tag 198 | (elfeed-protocol-newsblur--parse-categories host-url result)) 199 | (elfeed-protocol-newsblur--parse-feeds host-url result)) 200 | (when callback (funcall callback need-login)))))) 201 | 202 | (defun elfeed-protocol-newsblur--parse-feeds (host-url content) 203 | "Parse the feeds JSON buffer and fill results to db. 204 | HOST-URL is the host name of NewsBlur server. CONTENT is the 205 | result JSON content by http request. Return 206 | `elfeed-protocol-newsblur-feeds'." 207 | (let* ((proto-id (elfeed-protocol-newsblur-id host-url)) 208 | (feeds (map-elt content 'feeds))) 209 | (puthash proto-id feeds elfeed-protocol-newsblur-feeds) 210 | (cl-loop for feed in feeds do 211 | (let* ((fixed-feed (cdr feed)) 212 | (feed-url (map-elt fixed-feed 'feed_link)) 213 | (feed-id (elfeed-protocol-format-subfeed-id 214 | proto-id feed-url)) 215 | (feed-title (elfeed-cleanup (map-elt fixed-feed 'feed_title))) 216 | (feed-db (elfeed-db-get-feed feed-id))) 217 | (setf (elfeed-feed-url feed-db) feed-id 218 | (elfeed-feed-title feed-db) feed-title))) 219 | (elfeed-log 'debug "elfeed-protocol-newsblur: found %s feeds" (length feeds)) 220 | elfeed-protocol-newsblur-feeds)) 221 | 222 | (defun elfeed-protocol-newsblur--get-subfeed-url (host-url feed-id) 223 | "Get sub feed url for the newsblur protocol feed HOST-URL and FEED-ID." 224 | (let* ((url (catch 'found 225 | (let* ((proto-id (elfeed-protocol-newsblur-id host-url)) 226 | (feeds (gethash proto-id elfeed-protocol-newsblur-feeds)) 227 | (length (length feeds))) 228 | (dotimes (i length) 229 | (let* ((feed (elt feeds i)) 230 | (fixed-feed (cdr feed)) 231 | (id (map-elt fixed-feed 'id)) 232 | (url (map-elt fixed-feed 'feed_link))) 233 | (when (eq id feed-id) 234 | (throw 'found url)))))))) 235 | (unless url 236 | (setq url elfeed-protocol-unknown-feed-url) 237 | (elfeed-log 'warn "elfeed-protocol-newsblur: no subfeed for feed id %s, fallback to unknown feed" feed-id)) 238 | url)) 239 | 240 | (defun elfeed-protocol-newsblur--get-subfeed-id (host-url feed-url) 241 | "Get sub feed id for the newsblur protocol feed HOST-URL and FEED-URL." 242 | (let* ((id (catch 'found 243 | (let* ((proto-id (elfeed-protocol-newsblur-id host-url)) 244 | (feeds (gethash proto-id elfeed-protocol-newsblur-feeds)) 245 | (length (length feeds))) 246 | (dotimes (i length) 247 | (let* ((feed (elt feeds i)) 248 | (fixed-feed (cdr feed)) 249 | (id (map-elt fixed-feed 'id)) 250 | (url (map-elt fixed-feed 'feed_link))) 251 | (when (string= url feed-url) 252 | (throw 'found id)))))))) 253 | (unless id 254 | (elfeed-log 'error "elfeed-protocol-newsblur: no subfeed for feed url %s" feed-url)) 255 | id)) 256 | 257 | (defun elfeed-protocol-newsblur-entry-p (entry) 258 | "Check if specific ENTRY is fetched from NewsBlur." 259 | (let* ((proto-id (elfeed-protocol-entry-protocol-id entry)) 260 | (proto-type (when proto-id (elfeed-protocol-type proto-id)))) 261 | (string= proto-type "newsblur"))) 262 | 263 | (defun elfeed-protocol-newsblur--parse-entries (host-url content &optional mark-state callback) 264 | "Parse the entries JSON buffer and fill results to elfeed db. 265 | HOST-URL is the host name of NewsBlur server. CONTENT is the result 266 | JSON content by http request. If MARK-STATE is nil, then just not 267 | update :last-modifed value. If CALLBACK is not nil, will call it with 268 | the result entries as argument. Return parsed entries." 269 | (if (> (hash-table-count elfeed-protocol-newsblur-feeds) 0) 270 | (let* ((proto-id (elfeed-protocol-newsblur-id host-url)) 271 | (begin-time (time-to-seconds)) 272 | (max-last-modified (elfeed-protocol-get-last-modified proto-id)) 273 | (headlines (map-elt content 'stories)) 274 | entries) 275 | (elfeed-log 'debug "elfeed-protocol-newsblur: parsing entries, last-modified: %d" 276 | (elfeed-protocol-get-last-modified proto-id)) 277 | (setq entries 278 | (cl-loop for headline across headlines collect 279 | (pcase-let* (((map ('story_hash id) ('story_permalink entry-url) 280 | ('story_title title) ('story_authors author) 281 | ('story_content body) ('story_tags newsblur-tags) 282 | ('story_feed_id feed-id) ('guid_hash guid-hash) 283 | ;; ('image_urls image-urls) 284 | ) 285 | headline) 286 | (pub-date (string-to-number (map-elt headline 'story_timestamp))) 287 | (feed-url (elfeed-protocol-newsblur--get-subfeed-url host-url feed-id)) 288 | (unread (eq (map-elt headline 'read_status) 0)) 289 | (starred (and (map-elt headline 'starred) 290 | (not (eq (map-elt headline 'starred) 291 | ':json-false)))) 292 | (namespace (elfeed-url-to-namespace feed-url)) 293 | (full-id (cons namespace (elfeed-cleanup guid-hash))) 294 | (original (elfeed-db-get-entry full-id)) 295 | (original-date (and original 296 | (elfeed-entry-date original))) 297 | (category-name (when elfeed-protocol-newsblur-fetch-category-as-tag 298 | (elfeed-protocol-newsblur--get-category-name 299 | host-url feed-id))) 300 | (autotags (elfeed-protocol-feed-autotags proto-id feed-url)) 301 | (fixtags (elfeed-normalize-tags 302 | autotags elfeed-initial-tags)) 303 | (tags (progn 304 | (unless unread 305 | (setq fixtags (delete 'unread fixtags))) 306 | (when starred 307 | (push elfeed-protocol-newsblur-star-tag fixtags)) 308 | (when category-name 309 | (push (intern category-name) fixtags)) 310 | (when elfeed-protocol-newsblur-fetch-tags 311 | (dotimes (i (length newsblur-tags)) 312 | (let ((tag (elt newsblur-tags i))) 313 | (unless (string-empty-p tag) 314 | (push (intern tag) fixtags))))) 315 | fixtags)) 316 | (db-entry (elfeed-entry--create 317 | :title (elfeed-cleanup title) 318 | :id full-id 319 | :feed-id (elfeed-protocol-format-subfeed-id 320 | proto-id feed-url) 321 | :link (elfeed-cleanup entry-url) 322 | :tags tags 323 | :date (elfeed-new-date-for-entry 324 | original-date pub-date) 325 | ;; :enclosures nil ;TODO: fill image-urls mime 326 | :content body 327 | :content-type 'html 328 | :meta `(,@(elfeed-protocol-build-meta-author author) 329 | ,@(list :protocol-id proto-id 330 | :id id 331 | :guid-hash guid-hash 332 | :feed-id feed-id))))) 333 | ;; force override unread and star tags without repeat sync operation 334 | (when original 335 | (if unread (elfeed-tag-1 original 'unread) 336 | (elfeed-untag-1 original 'unread)) 337 | (if starred (elfeed-tag-1 original elfeed-protocol-newsblur-star-tag) 338 | (elfeed-untag-1 original elfeed-protocol-newsblur-star-tag))) 339 | 340 | ;; calculate the last modified time 341 | (when (> pub-date max-last-modified) 342 | (setq max-last-modified pub-date)) 343 | 344 | (dolist (hook elfeed-new-entry-parse-hook) 345 | (run-hook-with-args hook :newsblur headline db-entry)) 346 | db-entry))) 347 | (elfeed-db-add entries) 348 | (when callback (funcall callback entries)) 349 | 350 | ;; update last modified time 351 | (when (and mark-state (> max-last-modified 0)) 352 | (elfeed-protocol-set-last-modified proto-id max-last-modified)) 353 | 354 | (elfeed-log 'debug "elfeed-protocol-newsblur: parsed %s entries with %fs, last-modified: %d" 355 | (length entries) (- (time-to-seconds) begin-time) 356 | (elfeed-protocol-get-last-modified proto-id)) 357 | entries) 358 | (progn 359 | (elfeed-log 'error "elfeed-protocol-newsblur: elfeed-protocol-newsblur-feeds is nil, please call elfeed-protocol-newsblur--update-feed-list first") 360 | nil))) 361 | 362 | (defun elfeed-protocol-newsblur--do-update (host-url action &optional arg callback) 363 | "Real newsblur protocol updating operations. 364 | HOST-URL is the host name of NewsBlur server, and user field 365 | authentication info is always required so could find the related 366 | protocol feed id correctly, for example 367 | \"https://user:pass@myhost.com\". ACTION could be init, update and 368 | update-subfeed. For init, will fetch starred and recent pages 369 | entries. For update, will fetch recent pages entries, the ARG is the 370 | page number. And for update-subfeed, will fetch entries for special 371 | feed, the ARG is the feed id. If CALLBACK is not nil, will call it 372 | with the result entries as argument." 373 | (elfeed-log 'debug "elfeed-protocol-newsblur: update entries with action %s, arg %s" action arg) 374 | (let* ((proto-id (elfeed-protocol-newsblur-id host-url))) 375 | (unless elfeed--inhibit-update-init-hooks 376 | (run-hooks 'elfeed-update-init-hooks)) 377 | (cond 378 | ;; init 379 | ((eq action 'init) 380 | (elfeed-protocol-set-last-modified proto-id 0) 381 | (elfeed-protocol-clean-pending-ids proto-id) 382 | (dotimes (i elfeed-protocol-newsblur-maxpages) 383 | (elfeed-protocol-newsblur-with-fetch 384 | (concat host-url (format 385 | elfeed-protocol-newsblur-api-reader-starred-stories (1+ i))) 386 | "GET" nil 387 | (elfeed-protocol-newsblur--parse-entries host-url result t callback) 388 | (run-hook-with-args 'elfeed-update-hooks host-url)) 389 | (elfeed-protocol-newsblur-with-fetch 390 | (concat host-url (format 391 | elfeed-protocol-newsblur-api-reader-river-stories (1+ i))) 392 | "GET" nil 393 | (elfeed-protocol-newsblur--parse-entries host-url result t callback) 394 | (run-hook-with-args 'elfeed-update-hooks host-url)))) 395 | ;; update entries 396 | ((eq action 'update) 397 | (dotimes (i elfeed-protocol-newsblur-maxpages) 398 | (elfeed-protocol-newsblur-with-fetch 399 | (concat host-url (format 400 | elfeed-protocol-newsblur-api-reader-river-stories (1+ i))) 401 | "GET" nil 402 | (elfeed-protocol-newsblur--parse-entries host-url result t callback) 403 | (run-hook-with-args 'elfeed-update-hooks host-url)))) 404 | ;; update entries for special sub feed 405 | ((eq action 'update-subfeed) 406 | (dotimes (i elfeed-protocol-newsblur-maxpages) 407 | (elfeed-protocol-newsblur-with-fetch 408 | (concat host-url (format elfeed-protocol-newsblur-api-reader-feed arg (1+ i))) 409 | "GET" nil 410 | (elfeed-protocol-newsblur--parse-entries host-url result t callback) 411 | (run-hook-with-args 'elfeed-update-hooks host-url))))))) 412 | 413 | (defun elfeed-protocol-newsblur-reinit (host-url) 414 | "Retry initial sync operation. 415 | Will fetch starred and recent entries from NewsBlur. HOST-URL is the 416 | host name of NewsBlur server." 417 | (interactive (list (elfeed-protocol-url 418 | (completing-read "Protocol Feed: " (elfeed-protocol-feed-list))))) 419 | (elfeed-protocol-newsblur-fetch-prepare 420 | host-url 421 | (elfeed-protocol-newsblur--do-update host-url 'init nil))) 422 | 423 | (defun elfeed-protocol-newsblur-build-story-hashes-args (entries) 424 | "Build story hashes arguments for ENTRIES." 425 | (let* (args) 426 | (dolist (entry entries) 427 | (let* ((arg (format "story_hash=%s" (elfeed-meta entry :id)))) 428 | (if args 429 | (setq args (concat args "&" arg)) 430 | (setq args arg)))) 431 | args)) 432 | 433 | (defun elfeed-protocol-newsblur-update-entry-state (host-url sub-url id) 434 | "Notify entries to be read/unread/starred/unstarred. 435 | HOST-URL is the host name of NewsBlur server. SUB-URL is the endpoint 436 | url. ID is the target entry id." 437 | (elfeed-protocol-newsblur-with-fetch 438 | (concat host-url sub-url) 439 | "POST" 440 | (format "story_hash=%s" id))) 441 | 442 | (defun elfeed-protocol-newsblur-mark-read (host-url id) 443 | "Notify multiple entries to be read. 444 | HOST-URL is the host name of NewsBlur server. ID is the target entry id." 445 | (elfeed-log 'debug "elfeed-protocol-newsblur: mark read, id: %s" id) 446 | (elfeed-protocol-newsblur-update-entry-state 447 | host-url elfeed-protocol-newsblur-api-reader-mark-story-read id)) 448 | 449 | (defun elfeed-protocol-newsblur-mark-unread (host-url id) 450 | "Notify multiple entries to be unread. 451 | HOST-URL is the host name of NewsBlur server. ID is the target entry id." 452 | (elfeed-log 'debug "elfeed-protocol-newsblur: mark unread, id: %s" id) 453 | (elfeed-protocol-newsblur-update-entry-state 454 | host-url elfeed-protocol-newsblur-api-reader-mark-story-unread id)) 455 | 456 | (defun elfeed-protocol-newsblur-mark-starred (host-url id) 457 | "Notify multiple entries to be starred. 458 | HOST-URL is the host name of NewsBlur server. ID is the target entry id." 459 | (elfeed-log 'debug "elfeed-protocol-newsblur: mark starred, id: %s" id) 460 | (elfeed-protocol-newsblur-update-entry-state 461 | host-url elfeed-protocol-newsblur-api-reader-mark-story-starred id)) 462 | 463 | (defun elfeed-protocol-newsblur-mark-unstarred (host-url id) 464 | "Notify multiple entries to be unstarred. 465 | HOST-URL is the host name of NewsBlur server. ID is the target entry id." 466 | (elfeed-log 'debug "elfeed-protocol-newsblur: mark unstarred, id: %s" id) 467 | (elfeed-protocol-newsblur-update-entry-state 468 | host-url elfeed-protocol-newsblur-api-reader-mark-story-unstarred id)) 469 | 470 | (defun elfeed-protocol-newsblur-sync-pending-ids (host-url) 471 | "Sync pending read/unread/starred/unstarred entry states to NewsBlur server. 472 | HOST-URL is the host name of NewsBlur server." 473 | (let* ((proto-id (elfeed-protocol-newsblur-id host-url)) 474 | (pending-read-ids (elfeed-protocol-get-pending-ids proto-id :pending-read)) 475 | (pending-unread-ids (elfeed-protocol-get-pending-ids proto-id :pending-unread)) 476 | (pending-starred-ids (elfeed-protocol-get-pending-ids proto-id :pending-starred)) 477 | (pending-unstarred-ids (elfeed-protocol-get-pending-ids proto-id :pending-unstarred))) 478 | (dolist (id pending-read-ids) (elfeed-protocol-newsblur-mark-read host-url id)) 479 | (dolist (id pending-unread-ids) (elfeed-protocol-newsblur-mark-unread host-url id)) 480 | (dolist (id pending-starred-ids) (elfeed-protocol-newsblur-mark-starred host-url id)) 481 | (dolist (id pending-unstarred-ids) (elfeed-protocol-newsblur-mark-unstarred host-url id)) 482 | (elfeed-protocol-clean-pending-ids proto-id))) 483 | 484 | (defun elfeed-protocol-newsblur-append-pending-id (host-url entry tag action) 485 | "Sync unread starred and published tag states to NewsBlur server. 486 | HOST-URL is the the host name of NewsBlur server. ENTRY is the target entry 487 | object. TAG is the action tag, for example unread, and 488 | `elfeed-protocol-newsblur-star-tag', ACTION could be add or remove." 489 | (when (elfeed-protocol-newsblur-entry-p entry) 490 | (let* ((proto-id (elfeed-protocol-newsblur-id host-url)) 491 | (id (elfeed-meta entry :id))) 492 | (cond 493 | ((eq action 'add) 494 | (cond 495 | ((eq tag 'unread) 496 | (elfeed-protocol-append-pending-ids proto-id :pending-unread (list id)) 497 | (elfeed-protocol-remove-pending-ids proto-id :pending-read (list id))) 498 | ((eq tag elfeed-protocol-newsblur-star-tag) 499 | (elfeed-protocol-append-pending-ids proto-id :pending-starred (list id)) 500 | (elfeed-protocol-remove-pending-ids proto-id :pending-unstarred (list id))))) 501 | ((eq action 'remove) 502 | (cond 503 | ((eq tag 'unread) 504 | (elfeed-protocol-append-pending-ids proto-id :pending-read (list id)) 505 | (elfeed-protocol-remove-pending-ids proto-id :pending-unread (list id))) 506 | ((eq tag elfeed-protocol-newsblur-star-tag) 507 | (elfeed-protocol-append-pending-ids proto-id :pending-unstarred (list id)) 508 | (elfeed-protocol-remove-pending-ids proto-id :pending-starred (list id))))))))) 509 | 510 | (defun elfeed-protocol-newsblur-pre-tag (host-url entries &rest tags) 511 | "Sync unread, starred and published states before tags added. 512 | HOST-URL is the host name of NewsBlur server. ENTRIES is the 513 | target entry objects. TAGS is the tags are adding now." 514 | (dolist (tag tags) 515 | (cl-loop for entry in entries 516 | unless (elfeed-tagged-p tag entry) 517 | do (elfeed-protocol-newsblur-append-pending-id host-url entry tag 'add))) 518 | (unless elfeed-protocol-lazy-sync 519 | (elfeed-protocol-newsblur-sync-pending-ids host-url))) 520 | 521 | (defun elfeed-protocol-newsblur-pre-untag (host-url entries &rest tags) 522 | "Sync unread, starred and published states before tags removed. 523 | HOST-URL is the host name of NewsBlur server. ENTRIES is the 524 | target entry objects. TAGS is the tags are removing now." 525 | (dolist (tag tags) 526 | (cl-loop for entry in entries 527 | when (elfeed-tagged-p tag entry) 528 | do (elfeed-protocol-newsblur-append-pending-id host-url entry tag 'remove))) 529 | (unless elfeed-protocol-lazy-sync 530 | (elfeed-protocol-newsblur-sync-pending-ids host-url))) 531 | 532 | (defun elfeed-protocol-newsblur-update-subfeed (host-url feed-url &optional callback) 533 | "Update entries under special sub feed in NewsBlur. 534 | HOST-URL is the host name of NewsBlur server, FEED-URL is the 535 | target sub feed url, if CALLBACK is not nil will call it with the 536 | result entries as argument." 537 | (interactive) 538 | (let* ((feed-id (elfeed-protocol-newsblur--get-subfeed-id host-url feed-url))) 539 | (when feed-id 540 | (elfeed-protocol-newsblur-fetch-prepare 541 | host-url 542 | (elfeed-protocol-newsblur--do-update host-url 'update-subfeed feed-id callback))))) 543 | 544 | (defun elfeed-protocol-newsblur-update (host-or-subfeed-url &optional callback) 545 | "NewsBlur protocol updater. 546 | HOST-OR-SUBFEED-URL could be the host name of NewsBlur server, and 547 | user field authentication info is always required so could find the 548 | related protocol feed id correctly, for example 549 | \"https://user@myhost.com\". And HOST-OR-SUBFEED-URL also could be 550 | the sub feed url, too, for example 551 | \"https://user@myhost.com::https://subfeed.com\". If CALLBACK is not 552 | nil will call it with the result entries as argument" 553 | (interactive (list (elfeed-protocol-url 554 | (completing-read "Protocol Feed: " (elfeed-protocol-feed-list))))) 555 | (let* ((host-url (elfeed-protocol-host-url host-or-subfeed-url)) 556 | (feed-url (elfeed-protocol-subfeed-url host-or-subfeed-url)) 557 | (proto-id (elfeed-protocol-newsblur-id host-url)) 558 | (last-modified (elfeed-protocol-get-last-modified proto-id))) 559 | (elfeed-protocol-add-unknown-feed proto-id) ; add unknown feed for fallback 560 | (elfeed-protocol-newsblur-sync-pending-ids host-url) 561 | (if feed-url (elfeed-protocol-newsblur-update-subfeed host-url feed-url callback) 562 | (elfeed-protocol-newsblur-fetch-prepare 563 | host-url 564 | (if (> last-modified 0) 565 | (elfeed-protocol-newsblur--do-update host-url 'update nil callback) 566 | (elfeed-protocol-newsblur--do-update host-url 'init nil callback)))))) 567 | 568 | (provide 'elfeed-protocol-newsblur) 569 | 570 | ;;; elfeed-protocol-newsblur.el ends here 571 | -------------------------------------------------------------------------------- /elfeed-protocol.el: -------------------------------------------------------------------------------- 1 | ;;; elfeed-protocol.el --- Provide fever/newsblur/owncloud/ttrss protocols for elfeed -*- lexical-binding: t; -*- 2 | 3 | ;; Author: Xu Fasheng 4 | ;; URL: https://github.com/fasheng/elfeed-protocol 5 | ;; Version: 0.3.2 6 | ;; Package-Version: 20170501.1349 7 | ;; Package-Requires : ((emacs "24.4") (elfeed "2.1.1") (cl-lib "0.5")) 8 | ;; Keywords: news 9 | 10 | ;;; Commentary: 11 | ;; elfeed-protocol provide extra protocols to make self-hosting RSS 12 | ;; readers like Fever, NewsBlur, ownCloud News and Tiny TIny RSS work 13 | ;; with elfeed. See the README for full documentation. 14 | ;; 15 | ;; Usage: 16 | ;; 17 | ;; ;; curl recommend 18 | ;; (setq elfeed-use-curl t) 19 | ;; (elfeed-set-timeout 36000) 20 | ;; (setq elfeed-curl-extra-arguments '("--insecure")) ;necessary for https without a trust certificate 21 | ;; 22 | ;; ;; setup extra protocol feeds 23 | ;; (setq elfeed-protocol-feeds '(("owncloud+https://user@myhost.com" 24 | ;; :password "my-password"))) 25 | ;; 26 | ;; ;; enable elfeed-protocol 27 | ;; (elfeed-protocol-enable) 28 | 29 | ;;; Code: 30 | 31 | (require 'cl-lib) 32 | (require 'elfeed) 33 | (require 'elfeed-protocol-common) 34 | 35 | (defgroup elfeed-protocol () 36 | "Provide extra protocol for elfeed." 37 | :group 'comm) 38 | 39 | (defcustom elfeed-protocol-feeds () 40 | "List of all feeds that elfeed-protocol should follow. 41 | Similar with `elfeed-feeds'. For example: 42 | 43 | (setq elfeed-protocol-feeds '(\"http://foo/\" 44 | (\"http://baz/\" comic) 45 | \"fever+https://user:pass@myhost1.com\" 46 | (\"newsblur+https://user@myhost2.com\" 47 | :password \"password\") 48 | (\"owncloud+https://user@myhost3.com\" 49 | :password-file \"~/.password\") 50 | (\"ttrss+https://user@myhost4.com\" 51 | :use-authinfo t) 52 | (\"fever+https://user@myhost5.com\" 53 | :password (password-store-get \"fever/app-pass\"))))" 54 | :group 'elfeed-protocol 55 | :type '(repeat (choice string 56 | (cons string (repeat symbol))))) 57 | 58 | (defcustom elfeed-protocol-list () 59 | "List of all registered extra protocols in Elfeed. 60 | 61 | Could be modified by `elfeed-protocol-register' and 62 | `elfeed-protocol-unregister'. 63 | 64 | For example, 65 | (elfeed-protocol-register \"owncloud\" 'elfeed-protocol-owncloud-update) 66 | (elfeed-protocol-unregister \"owncloud\")" 67 | :group 'elfeed-protocol 68 | :type '(repeat (cons string symbol))) 69 | 70 | (defcustom elfeed-protocol-enabled-protocols '(fever newsblur owncloud ttrss) 71 | "Protocols that should always be loaded together when elfeed-protocol-enable. 72 | 73 | You can also use this system to load external packages (i.e. neither elfeed-protocol 74 | core protocols, nor external protocols). Just add symbols 75 | to the end of the list. If the package is called elfeed-protocol-xyz.el, then you need 76 | to add the symbol `xyz', and the package must have a call to: 77 | 78 | (provide \\='elfeed-protocol-xyz)" 79 | :group 'elfeed-protocol 80 | :type '(repeat symbol)) 81 | 82 | (defun elfeed-protocol-update-func (proto-type) 83 | "Get update function for special PROTO-TYPE." 84 | (plist-get (cdr (assoc proto-type elfeed-protocol-list)) ':update)) 85 | 86 | (defun elfeed-protocol-pre-tag-func (proto-type) 87 | "Get pre-tag function for special PROTO-TYPE." 88 | (plist-get (cdr (assoc proto-type elfeed-protocol-list)) ':pre-tag)) 89 | 90 | (defun elfeed-protocol-pre-untag-func (proto-type) 91 | "Get pre-untag function for special PROTO-TYPE." 92 | (plist-get (cdr (assoc proto-type elfeed-protocol-list)) ':pre-untag)) 93 | 94 | (defun elfeed-protocol-register (proto-type proto-funcs) 95 | "Register PROTO-TYPE to `elfeed-protocol-list'. 96 | PROTO-FUNCS is a function list for :update :pre-tag(optinal) 97 | and :pre-untag(optinal) , 98 | 99 | For example: 100 | 101 | (list :update 'elfeed-protocol-xxx-update 102 | :pre-tag 'elfeed-protocol-xxx-pre-tag 103 | :pre-untag 'elfeed-protocol-xxx-pre-untag)" 104 | (if (elfeed-protocol-update-func proto-type) 105 | (setf (cdr (assoc proto-type elfeed-protocol-list)) proto-funcs) 106 | (add-to-list 'elfeed-protocol-list (cons proto-type proto-funcs)))) 107 | 108 | (defun elfeed-protocol-unregister (proto-type) 109 | "Unregister a protocol named PROTO-TYPE from `elfeed-protocol-list'." 110 | (setq elfeed-protocol-list 111 | (delq (assoc proto-type elfeed-protocol-list) elfeed-protocol-list))) 112 | 113 | (defun elfeed-protocol-on-tag-add (entries tags) 114 | "Dispatch for tags added. 115 | Will split ENTRIES to groups and dispatched TAGS by different protocols." 116 | (let* ((entry-groups (elfeed-protocol-build-entry-groups entries))) 117 | (maphash (lambda (proto-id proto-entries) 118 | (let* ((proto-type (elfeed-protocol-type proto-id)) 119 | (proto-url (elfeed-protocol-meta-url proto-id)) 120 | (host-url (elfeed-protocol-url proto-url)) 121 | (pre-tag-func (elfeed-protocol-pre-tag-func proto-type))) 122 | (when pre-tag-func 123 | (apply pre-tag-func host-url proto-entries tags)))) 124 | entry-groups))) 125 | 126 | (defun elfeed-protocol-on-tag-remove (entries tags) 127 | "Dispatch for tags removed. 128 | Will split ENTRIES to groups and dispatched TAGS by different protocols." 129 | (let* ((entry-groups (elfeed-protocol-build-entry-groups entries))) 130 | (maphash (lambda (proto-id proto-entries) 131 | (let* ((proto-type (elfeed-protocol-type proto-id)) 132 | (proto-url (elfeed-protocol-meta-url proto-id)) 133 | (host-url (elfeed-protocol-url proto-url)) 134 | (pre-untag-func (elfeed-protocol-pre-untag-func proto-type))) 135 | (when pre-untag-func 136 | (apply pre-untag-func host-url proto-entries tags)))) 137 | entry-groups))) 138 | 139 | (defun elfeed-protocol-advice-update-feed (orig-func url) 140 | "Advice for `elfeed-update-feed` to update protocol feed correctly. 141 | ORIG-FUNC and URL are the needed arguments." 142 | (interactive (list (completing-read "Feed: " (elfeed-feed-list)))) 143 | (if (elfeed-protocol-feed-p url) 144 | (let* ((proto-type (elfeed-protocol-type url)) 145 | (update-func (elfeed-protocol-update-func proto-type))) 146 | (if update-func 147 | (progn 148 | (unless elfeed--inhibit-update-init-hooks 149 | (run-hooks 'elfeed-update-init-hooks)) 150 | (funcall update-func (elfeed-protocol-url url)) 151 | (run-hook-with-args 'elfeed-update-hooks url)) 152 | (elfeed-log 'error "elfeed-protocol: there is not updater for protocol %s" 153 | proto-type))) 154 | (funcall orig-func url))) 155 | 156 | (defun elfeed-protocol-advice-feed-list () 157 | "Advice for `elfeed-feed-list' to avoid error checking on protocol feeds and use 158 | `elfeed-protocol-feeds' instead of `elfeed-feeds'." 159 | (when (eq (length elfeed-protocol-feeds) 0) 160 | (elfeed-log 'warn "elfeed-protocol: elfeed-protocol-feeds is empty, please setup it instead of elfeed-feeds since 0.9.0")) 161 | (cl-loop for feed in elfeed-protocol-feeds 162 | when (listp feed) collect (car feed) 163 | else collect feed)) 164 | 165 | ;;;###autoload 166 | (defun elfeed-protocol-enable () 167 | "Enable hooks and advices for elfeed-protocol." 168 | (interactive) 169 | (advice-add 'elfeed-feed-list :override #'elfeed-protocol-advice-feed-list) 170 | (advice-add 'elfeed-update-feed :around #'elfeed-protocol-advice-update-feed) 171 | (add-hook 'elfeed-tag-hooks 'elfeed-protocol-on-tag-add) 172 | (add-hook 'elfeed-untag-hooks 'elfeed-protocol-on-tag-remove) 173 | (dolist (protocol elfeed-protocol-enabled-protocols) 174 | (let ((feature (intern (concat "elfeed-protocol-" (symbol-name protocol))))) 175 | (if (require feature nil t) 176 | (elfeed-protocol-register 177 | (symbol-name protocol) 178 | (list :update (intern (concat (symbol-name feature) "-update")) 179 | :pre-tag (intern (concat (symbol-name feature) "-pre-tag")) 180 | :pre-untag (intern (concat (symbol-name feature) "-pre-untag")))) 181 | (error "Problems while trying to load feature `%s'" feature))))) 182 | 183 | ;;;###autoload 184 | (defun elfeed-protocol-disable () 185 | "Disable hooks and advices for elfeed-protocol." 186 | (interactive) 187 | (advice-remove 'elfeed-feed-list #'elfeed-protocol-advice-feed-list) 188 | (advice-remove 'elfeed-update-feed #'elfeed-protocol-advice-update-feed) 189 | (remove-hook 'elfeed-tag-hooks 'elfeed-protocol-on-tag-add) 190 | (remove-hook 'elfeed-untag-hooks 'elfeed-protocol-on-tag-remove) 191 | (dolist (protocol elfeed-protocol-enabled-protocols) 192 | (elfeed-protocol-unregister (symbol-name protocol)))) 193 | 194 | (provide 'elfeed-protocol) 195 | 196 | ;;; elfeed-protocol.el ends here 197 | -------------------------------------------------------------------------------- /test/elfeed-protocol-fever-test.el: -------------------------------------------------------------------------------- 1 | (require 'cl-lib) 2 | (require 'ert) 3 | (require 'elfeed) 4 | 5 | (defvar elfeed-protocol-fever-fixture-dir (concat (file-name-directory load-file-name) "fixtures/fever/")) 6 | 7 | (defvar elfeed-protocol-fever-fixture-categories 8 | (concat elfeed-protocol-fever-fixture-dir "categories.json")) 9 | 10 | (defvar elfeed-protocol-fever-fixture-feeds 11 | (concat elfeed-protocol-fever-fixture-dir "feeds.json")) 12 | 13 | (defvar elfeed-protocol-fever-fixture-entries 14 | (concat elfeed-protocol-fever-fixture-dir "entries.json")) 15 | 16 | (ert-deftest elfeed-protocol-fever-parse-categories () 17 | (with-elfeed-test 18 | (with-fixture elfeed-protocol-fever-fixture-categories 19 | (let* ((proto-url "fever+https://user:pass@myhost.com") 20 | (host-url (elfeed-protocol-url proto-url)) 21 | (proto-id (elfeed-protocol-fever-id host-url)) 22 | (elfeed-protocol-fever-categories (elfeed-protocol-fever--parse-result 23 | (elfeed-protocol-fever--parse-categories 24 | host-url result)))) 25 | (should (gethash proto-id elfeed-protocol-fever-categories)) 26 | (should (string-equal 27 | (elfeed-protocol-fever--get-category-name host-url 1) 28 | "Category 1")) 29 | ;; for invalid feed 30 | (should (not (elfeed-protocol-fever--get-category-name host-url 12345))))))) 31 | 32 | (ert-deftest elfeed-protocol-fever-parse-feeds () 33 | (with-elfeed-test 34 | (with-fixture elfeed-protocol-fever-fixture-feeds 35 | (let* ((proto-url "fever+https://user:pass@myhost.com") 36 | (host-url (elfeed-protocol-url proto-url)) 37 | (proto-id (elfeed-protocol-fever-id host-url)) 38 | (elfeed-protocol-feeds (list proto-url)) 39 | (elfeed-protocol-fever-feeds (elfeed-protocol-fever--parse-result 40 | (elfeed-protocol-fever--parse-feeds 41 | host-url result))) 42 | (test-feed-url (elfeed-protocol-fever--get-subfeed-url host-url 1)) 43 | (test-feed (elfeed-db-get-feed 44 | (elfeed-protocol-format-subfeed-id proto-id test-feed-url)))) 45 | (should (string= 46 | test-feed-url 47 | "http://tt-rss.org/forum/rss.php")) 48 | (should (string= 49 | (elfeed-feed-url test-feed) 50 | (elfeed-protocol-format-subfeed-id proto-id "http://tt-rss.org/forum/rss.php"))) 51 | (should (string= 52 | (elfeed-feed-title test-feed) 53 | "Tiny Tiny RSS: Forum")))))) 54 | 55 | (ert-deftest elfeed-protocol-fever-parse-entries () 56 | (with-elfeed-test 57 | (with-fixture elfeed-protocol-fever-fixture-categories 58 | (let* ((proto-url "fever+https://user:pass@myhost.com") 59 | (host-url (elfeed-protocol-url proto-url)) 60 | (proto-id (elfeed-protocol-fever-id host-url)) 61 | (elfeed-protocol-fever-categories (elfeed-protocol-fever--parse-result 62 | (elfeed-protocol-fever--parse-categories 63 | host-url result)))) 64 | (with-fixture elfeed-protocol-fever-fixture-feeds 65 | (let* ((proto-url "fever+https://user:pass@myhost.com") 66 | (host-url (elfeed-protocol-url proto-url)) 67 | (proto-id (elfeed-protocol-fever-id host-url)) 68 | (elfeed-protocol-feeds (list (list proto-url 69 | :autotags 70 | '(("http://tt-rss.org/forum/rss.php" ttrss) 71 | ("https://github.com/FreshRSS/FreshRSS/releases.atom" freshrss))))) 72 | (elfeed-protocol-fever-feeds (elfeed-protocol-fever--parse-result 73 | (elfeed-protocol-fever--parse-feeds 74 | host-url result)))) 75 | (with-fixture elfeed-protocol-fever-fixture-entries 76 | (let* ((entries (elfeed-protocol-fever--parse-result 77 | (elfeed-protocol-fever--parse-entries 78 | host-url (map-elt result 'items)))) 79 | (entry1 (elt entries 0)) 80 | (entry2 (elt entries 1)) 81 | (entry3 (elt entries 2)) 82 | (entry4 (elt entries 3))) 83 | (should (elfeed-protocol-fever-entry-p entry1)) 84 | (should (elfeed-protocol-fever-entry-p entry2)) 85 | (should (elfeed-protocol-fever-entry-p entry3)) 86 | (should (elfeed-protocol-fever-entry-p entry4)) 87 | (should (string= 88 | (elfeed-entry-title entry1) 89 | "Pictures not shown in some feeds with figure block")) 90 | (should (string= 91 | (elfeed-entry-title entry2) 92 | "PDO is coming, here's what you need to know")) 93 | (should (string= 94 | (elfeed-entry-title entry3) 95 | "FreshRSS 1.13.1")) 96 | (should (string= 97 | (elfeed-entry-title entry4) 98 | "Cloned FreshRSS 1.13.1")) 99 | (should (string= 100 | (plist-get (nth 0 (elfeed-meta entry1 :authors)) :name) 101 | "author1")) 102 | (should (string= 103 | (plist-get (nth 0 (elfeed-meta entry2 :authors)) :name) 104 | "author2")) 105 | (should (equal 106 | (elfeed-entry-tags entry1) 107 | '(Category\ 1 ttrss))) 108 | (should (equal 109 | (elfeed-entry-tags entry2) 110 | '(Category\ 1 star ttrss unread))) 111 | (should (equal 112 | (elfeed-entry-tags entry3) 113 | '(freshrss))) 114 | (should (equal 115 | (elfeed-entry-tags entry4) 116 | '(freshrss))))))))))) 117 | -------------------------------------------------------------------------------- /test/elfeed-protocol-newsblur-test.el: -------------------------------------------------------------------------------- 1 | (require 'cl-lib) 2 | (require 'ert) 3 | (require 'elfeed) 4 | 5 | (defvar elfeed-protocol-newsblur-fixture-dir (concat (file-name-directory load-file-name) "fixtures/newsblur/")) 6 | 7 | (defvar elfeed-protocol-newsblur-fixture-feeds 8 | (concat elfeed-protocol-newsblur-fixture-dir "feeds.json")) 9 | 10 | (defvar elfeed-protocol-newsblur-fixture-entries 11 | (concat elfeed-protocol-newsblur-fixture-dir "entries.json")) 12 | 13 | (ert-deftest elfeed-protocol-newsblur-parse-categories () 14 | (with-elfeed-test 15 | (with-fixture elfeed-protocol-newsblur-fixture-feeds 16 | (let* ((proto-url "newsblur+https://user:pass@myhost.com") 17 | (host-url (elfeed-protocol-url proto-url)) 18 | (proto-id (elfeed-protocol-newsblur-id host-url)) 19 | (elfeed-protocol-newsblur-categories (elfeed-protocol-newsblur--parse-result 20 | (elfeed-protocol-newsblur--parse-categories 21 | host-url result)))) 22 | (should (gethash proto-id elfeed-protocol-newsblur-categories)) 23 | (should (string-equal 24 | (elfeed-protocol-newsblur--get-category-name host-url 569) 25 | "Writers")) 26 | (should (string-equal 27 | (elfeed-protocol-newsblur--get-category-name host-url 1186180) 28 | "Blogs")) 29 | (should (string-equal 30 | (elfeed-protocol-newsblur--get-category-name host-url 50) 31 | "Blogs/Photoblogs")) 32 | ;; for feed without category 33 | (should (not (elfeed-protocol-newsblur--get-category-name host-url 8032018))) 34 | ;; for invalid feed 35 | (should (not (elfeed-protocol-newsblur--get-category-name host-url 12345))))))) 36 | 37 | (ert-deftest elfeed-protocol-newsblur-parse-feeds () 38 | (with-elfeed-test 39 | (with-fixture elfeed-protocol-newsblur-fixture-feeds 40 | (let* ((proto-url "newsblur+https://user:pass@newsblur.com") 41 | (host-url (elfeed-protocol-url proto-url)) 42 | (proto-id (elfeed-protocol-newsblur-id host-url)) 43 | (elfeed-protocol-feeds (list proto-url)) 44 | (elfeed-protocol-newsblur-feeds (elfeed-protocol-newsblur--parse-result 45 | (elfeed-protocol-newsblur--parse-feeds 46 | host-url result))) 47 | (test-orig-feed-url (elfeed-protocol-newsblur--get-subfeed-url host-url 569)) 48 | (test-feed (elfeed-db-get-feed 49 | (elfeed-protocol-format-subfeed-id proto-id test-orig-feed-url)))) 50 | (should (string= 51 | test-orig-feed-url 52 | "http://anildash.com/")) 53 | (should (string= 54 | (elfeed-feed-url test-feed) 55 | (elfeed-protocol-format-subfeed-id proto-id "http://anildash.com/"))) 56 | (should (string= 57 | (elfeed-feed-title test-feed) 58 | "Anil Dash")))))) 59 | 60 | (ert-deftest elfeed-protocol-newsblur-parse-entries () 61 | (with-elfeed-test 62 | (with-fixture elfeed-protocol-newsblur-fixture-feeds 63 | (let* ((proto-url "newsblur+https://user:pass@myhost.com") 64 | (host-url (elfeed-protocol-url proto-url)) 65 | (proto-id (elfeed-protocol-newsblur-id host-url)) 66 | (elfeed-protocol-newsblur-categories (elfeed-protocol-newsblur--parse-result 67 | (elfeed-protocol-newsblur--parse-categories 68 | host-url result)))) 69 | (with-fixture elfeed-protocol-newsblur-fixture-feeds 70 | (let* ((proto-url "newsblur+https://user:pass@myhost.com") 71 | (host-url (elfeed-protocol-url proto-url)) 72 | (proto-id (elfeed-protocol-newsblur-id host-url)) 73 | (elfeed-protocol-feeds (list (list proto-url 74 | :autotags 75 | '(("http://anildash.com/" tag1))))) 76 | (elfeed-protocol-newsblur-feeds (elfeed-protocol-newsblur--parse-result 77 | (elfeed-protocol-newsblur--parse-feeds 78 | host-url result)))) 79 | (with-fixture elfeed-protocol-newsblur-fixture-entries 80 | (let* ((entries (elfeed-protocol-newsblur--parse-result 81 | (elfeed-protocol-newsblur--parse-entries 82 | host-url result))) 83 | (entry1 (elt entries 0)) 84 | (entry2 (elt entries 1))) 85 | (should (elfeed-protocol-newsblur-entry-p entry1)) 86 | (should (elfeed-protocol-newsblur-entry-p entry2)) 87 | (should (string= 88 | (elfeed-entry-title entry1) 89 | "Ask HN: What software/service helps you be an effective remote developer?")) 90 | (should (string= 91 | (elfeed-entry-title entry2) 92 | "Jessica Jones’ second season gets its first teaser")) 93 | (should (string= 94 | (plist-get (nth 0 (elfeed-meta entry1 :authors)) :name) 95 | "pearphp")) 96 | (should (string= 97 | (plist-get (nth 0 (elfeed-meta entry2 :authors)) :name) 98 | "Andrew Liptak")) 99 | (should (equal 100 | (elfeed-entry-tags entry1) 101 | '(Writers tag1))) 102 | (should (equal 103 | (elfeed-entry-tags entry2) 104 | `(hyperloop ,(intern "fundings & exits") Blogs star unread))))))))))) 105 | -------------------------------------------------------------------------------- /test/elfeed-protocol-owncloud-test.el: -------------------------------------------------------------------------------- 1 | (require 'cl-lib) 2 | (require 'ert) 3 | (require 'elfeed) 4 | 5 | (defvar elfeed-protocol-owncloud-fixture-dir (concat (file-name-directory load-file-name) "fixtures/owncloud/")) 6 | 7 | (defvar elfeed-protocol-owncloud-fixture-categories 8 | (concat elfeed-protocol-owncloud-fixture-dir "categories.json")) 9 | 10 | (defvar elfeed-protocol-owncloud-fixture-feeds 11 | (concat elfeed-protocol-owncloud-fixture-dir "feeds.json")) 12 | 13 | (defvar elfeed-protocol-owncloud-fixture-entries 14 | (concat elfeed-protocol-owncloud-fixture-dir "entries.json")) 15 | 16 | (ert-deftest elfeed-protocol-owncloud-parse-categories () 17 | (with-elfeed-test 18 | (with-fixture elfeed-protocol-owncloud-fixture-categories 19 | (let* ((proto-url "owncloud+https://user:pass@myhost.com:443") 20 | (host-url (elfeed-protocol-url proto-url)) 21 | (proto-id (elfeed-protocol-owncloud-id host-url)) 22 | (elfeed-protocol-owncloud-categories (elfeed-protocol-owncloud--parse-result 23 | (elfeed-protocol-owncloud--parse-categories 24 | host-url result)))) 25 | (should (gethash proto-id elfeed-protocol-owncloud-categories)) 26 | (should (string-equal 27 | (elfeed-protocol-owncloud--get-category-name host-url 1) 28 | "Category 1")) 29 | ;; for invalid feed 30 | (should (not (elfeed-protocol-owncloud--get-category-name host-url 12345))))))) 31 | 32 | (ert-deftest elfeed-protocol-owncloud-parse-feeds () 33 | (with-elfeed-test 34 | (with-fixture elfeed-protocol-owncloud-fixture-feeds 35 | (let* ((url "https://user:pass@myhost.com:443") 36 | (proto-url (concat "owncloud+" url)) 37 | (proto-id (elfeed-protocol-owncloud-id url)) 38 | (elfeed-protocol-feeds (list proto-url)) 39 | (elfeed-protocol-owncloud-feeds (elfeed-protocol-owncloud--parse-result 40 | (elfeed-protocol-owncloud--parse-feeds url result))) 41 | (feed1-url (elfeed-protocol-owncloud--get-subfeed-url url 1)) 42 | (feed1 (elfeed-db-get-feed 43 | (elfeed-protocol-format-subfeed-id proto-id feed1-url))) 44 | (feed2-url (elfeed-protocol-owncloud--get-subfeed-url url 2)) 45 | (feed2 (elfeed-db-get-feed 46 | (elfeed-protocol-format-subfeed-id proto-id feed2-url)))) 47 | (should (string= 48 | feed1-url 49 | "http://www.example.com/feed/")) 50 | (should (string= 51 | feed2-url 52 | "http://www.example2.com/rss.jsp")) 53 | (should (string= 54 | (elfeed-feed-url feed1) 55 | (elfeed-protocol-format-subfeed-id proto-id "http://www.example.com/feed/"))) 56 | (should (string= 57 | (elfeed-feed-url feed2) 58 | (elfeed-protocol-format-subfeed-id proto-id "http://www.example2.com/rss.jsp"))) 59 | (should (string= 60 | (elfeed-feed-title feed1) 61 | "Feed 1")) 62 | (should (string= 63 | (elfeed-feed-title feed2) 64 | "Feed 2")))))) 65 | 66 | (ert-deftest elfeed-protocol-owncloud-parse-entries () 67 | (with-elfeed-test 68 | (with-fixture elfeed-protocol-owncloud-fixture-categories 69 | (let* ((proto-url "owncloud+https://user:pass@myhost.com:443") 70 | (host-url (elfeed-protocol-url proto-url)) 71 | (proto-id (elfeed-protocol-owncloud-id host-url)) 72 | (elfeed-protocol-owncloud-categories (elfeed-protocol-owncloud--parse-result 73 | (elfeed-protocol-owncloud--parse-categories 74 | host-url result)))) 75 | (with-fixture elfeed-protocol-owncloud-fixture-feeds 76 | (let* ((url "https://user:pass@myhost.com:443") 77 | (proto-url (concat "owncloud+" url)) 78 | (proto-id (elfeed-protocol-owncloud-id url)) 79 | (elfeed-protocol-feeds (list (list proto-url :autotags 80 | '(("http://www.example.com/feed/" tag1) 81 | ("http://www.example2.com/rss.jsp" tag2))))) 82 | (elfeed-protocol-owncloud-feeds (elfeed-protocol-owncloud--parse-result 83 | (elfeed-protocol-owncloud--parse-feeds url result)))) 84 | (with-fixture elfeed-protocol-owncloud-fixture-entries 85 | (let* ((entries (elfeed-protocol-owncloud--parse-result 86 | (elfeed-protocol-owncloud--parse-entries url result))) 87 | (entry1 (elt entries 0)) 88 | (entry2 (elt entries 1))) 89 | (should (elfeed-protocol-owncloud-entry-p entry1)) 90 | (should (elfeed-protocol-owncloud-entry-p entry2)) 91 | (should (string= 92 | (elfeed-entry-title entry1) 93 | "Entry 1")) 94 | (should (string= 95 | (elfeed-entry-title entry2) 96 | "Entry 2")) 97 | (should (string= 98 | (plist-get (nth 0 (elfeed-meta entry1 :authors)) :name) 99 | "author1 ")) 100 | (should (string= 101 | (plist-get (nth 0 (elfeed-meta entry2 :authors)) :name) 102 | "author2 ")) 103 | (should (equal 104 | (elfeed-entry-tags entry1) 105 | '(Category\ 1 tag1))) 106 | (should (equal 107 | (elfeed-entry-tags entry2) 108 | '(star tag2 unread))))))))))) 109 | -------------------------------------------------------------------------------- /test/elfeed-protocol-test.el: -------------------------------------------------------------------------------- 1 | (require 'cl-lib) 2 | (require 'ert) 3 | (require 'elfeed) 4 | 5 | (ert-deftest elfeed-protocol-register () 6 | (let* (elfeed-protocol-list) 7 | (elfeed-protocol-register "owncloud" (list :update 'elfeed-protocol-owncloud-update 8 | :pre-tag 'elfeed-protocol-owncloud-pre-tag 9 | :pre-untag 'elfeed-protocol-owncloud-pre-untag)) 10 | (should (eq (elfeed-protocol-update-func "owncloud") 'elfeed-protocol-owncloud-update)) 11 | (should (eq (elfeed-protocol-pre-tag-func "owncloud") 'elfeed-protocol-owncloud-pre-tag)) 12 | (should (eq (elfeed-protocol-pre-untag-func "owncloud") 'elfeed-protocol-owncloud-pre-untag)) 13 | (elfeed-protocol-unregister "owncloud") 14 | (should (eq (elfeed-protocol-update-func "owncloud") nil)))) 15 | 16 | (ert-deftest elfeed-protocol-common () 17 | (should (string= 18 | (elfeed-protocol-no-auth-url "https://myhost.com") 19 | "https://myhost.com")) 20 | (should (string= 21 | (elfeed-protocol-no-auth-url "https://user1@myhost.com") 22 | "https://myhost.com")) 23 | (should (string= 24 | (elfeed-protocol-no-auth-url "https://user1:pass1@myhost.com") 25 | "https://myhost.com"))) 26 | 27 | (ert-deftest elfeed-protocol-meta-data () 28 | (with-elfeed-test 29 | (let* ((elfeed-protocol-feeds '("owncloud+https://user1:pass1@myhost.com:443" 30 | ("owncloud+https://user2@domain.com@myhost.com" 31 | ;; :user "user2@domain.com" 32 | :password "pass2/with|special@characters:"))) 33 | (proto-id1 "owncloud+https://user1@myhost.com:443") 34 | (proto-id2 "owncloud+https://user2@domain.com@myhost.com")) 35 | (should (string= 36 | (elfeed-protocol-type "owncloud+https://user1:pass1@myhost.com:443") 37 | "owncloud")) 38 | (should (string= 39 | (elfeed-protocol-url "owncloud+https://user1:pass1@myhost.com:443") 40 | "https://user1:pass1@myhost.com:443")) 41 | (should (string= 42 | (elfeed-protocol-meta-url proto-id1) 43 | "owncloud+https://user1:pass1@myhost.com:443")) 44 | (should (string= 45 | (elfeed-protocol-meta-url proto-id2) 46 | "owncloud+https://user2@domain.com@myhost.com")) 47 | (should (string= 48 | (elfeed-protocol-meta-user proto-id1) 49 | "user1")) 50 | (should (string= 51 | (elfeed-protocol-meta-user proto-id2) 52 | "user2@domain.com")) 53 | (should (string= 54 | (elfeed-protocol-meta-password proto-id1) 55 | "pass1")) 56 | (should (string= 57 | (elfeed-protocol-meta-password proto-id2) 58 | "pass2/with|special@characters:"))))) 59 | -------------------------------------------------------------------------------- /test/elfeed-protocol-ttrss-test.el: -------------------------------------------------------------------------------- 1 | (require 'cl-lib) 2 | (require 'ert) 3 | (require 'elfeed) 4 | 5 | (defvar elfeed-protocol-ttrss-fixture-dir (concat (file-name-directory load-file-name) "fixtures/ttrss/")) 6 | 7 | (defvar elfeed-protocol-ttrss-fixture-categories 8 | (concat elfeed-protocol-ttrss-fixture-dir "categories.json")) 9 | 10 | (defvar elfeed-protocol-ttrss-fixture-feeds 11 | (concat elfeed-protocol-ttrss-fixture-dir "feeds.json")) 12 | 13 | (defvar elfeed-protocol-ttrss-fixture-entries 14 | (concat elfeed-protocol-ttrss-fixture-dir "entries.json")) 15 | 16 | (defvar elfeed-protocol-ttrss-fixture-no-feed-id-entries 17 | (concat elfeed-protocol-ttrss-fixture-dir "entries-no-feed-id.json")) 18 | 19 | (ert-deftest elfeed-protocol-ttrss-parse-categories () 20 | (with-elfeed-test 21 | (with-fixture elfeed-protocol-ttrss-fixture-categories 22 | (let* ((proto-url "ttrss+https://user:pass@myhost.com") 23 | (host-url (elfeed-protocol-url proto-url)) 24 | (proto-id (elfeed-protocol-ttrss-id host-url)) 25 | (elfeed-protocol-ttrss-categories (elfeed-protocol-ttrss--parse-result 26 | (elfeed-protocol-ttrss--parse-categories 27 | host-url content)))) 28 | (should (gethash proto-id elfeed-protocol-ttrss-categories)) 29 | (should (string-equal 30 | (elfeed-protocol-ttrss--get-category-name host-url 2) 31 | "Emacs")) 32 | ;; for invalid feed 33 | (should (not (elfeed-protocol-ttrss--get-category-name host-url 12345))))))) 34 | 35 | (ert-deftest elfeed-protocol-ttrss-parse-feeds () 36 | (with-elfeed-test 37 | (with-fixture elfeed-protocol-ttrss-fixture-feeds 38 | (let* ((proto-url "ttrss+https://user:pass@myhost.com:443") 39 | (host-url (elfeed-protocol-url proto-url)) 40 | (proto-id (elfeed-protocol-ttrss-id host-url)) 41 | (elfeed-protocol-feeds (list proto-url)) 42 | (elfeed-protocol-ttrss-feeds (elfeed-protocol-ttrss--parse-result 43 | (elfeed-protocol-ttrss--parse-feeds 44 | host-url content))) 45 | (test-feed-url (elfeed-protocol-ttrss--get-subfeed-url host-url 1)) 46 | (test-feed (elfeed-db-get-feed 47 | (elfeed-protocol-format-subfeed-id proto-id test-feed-url)))) 48 | (should (string= 49 | test-feed-url 50 | "http://tt-rss.org/forum/rss.php")) 51 | (should (string= 52 | (elfeed-feed-url test-feed) 53 | (elfeed-protocol-format-subfeed-id proto-id "http://tt-rss.org/forum/rss.php"))) 54 | (should (string= 55 | (elfeed-feed-title test-feed) 56 | "Tiny Tiny RSS: Forum")))))) 57 | 58 | (ert-deftest elfeed-protocol-ttrss-parse-entries () 59 | (with-elfeed-test 60 | (with-fixture elfeed-protocol-ttrss-fixture-categories 61 | (let* ((proto-url "ttrss+https://user:pass@myhost.com") 62 | (host-url (elfeed-protocol-url proto-url)) 63 | (proto-id (elfeed-protocol-ttrss-id host-url)) 64 | (elfeed-protocol-ttrss-categories (elfeed-protocol-ttrss--parse-result 65 | (elfeed-protocol-ttrss--parse-categories 66 | host-url content)))) 67 | (with-fixture elfeed-protocol-ttrss-fixture-feeds 68 | (let* ((elfeed-protocol-feeds (list (list proto-url 69 | :autotags 70 | '(("http://tt-rss.org/forum/rss.php" tag1))))) 71 | (elfeed-protocol-ttrss-feeds (elfeed-protocol-ttrss--parse-result 72 | (elfeed-protocol-ttrss--parse-feeds 73 | host-url content)))) 74 | (with-fixture elfeed-protocol-ttrss-fixture-entries 75 | (let* ((entries (elfeed-protocol-ttrss--parse-result 76 | (elfeed-protocol-ttrss--parse-entries 77 | host-url content))) 78 | (entry1 (elt entries 0)) 79 | (entry2 (elt entries 1))) 80 | (should (elfeed-protocol-ttrss-entry-p entry1)) 81 | (should (elfeed-protocol-ttrss-entry-p entry2)) 82 | (should (string= 83 | (elfeed-entry-title entry1) 84 | "Pictures not shown in some feeds with figure block")) 85 | (should (string= 86 | (elfeed-entry-title entry2) 87 | "PDO is coming, here's what you need to know")) 88 | (should (string= 89 | (plist-get (nth 0 (elfeed-meta entry1 :authors)) :name) 90 | "@author1")) 91 | (should (string= 92 | (plist-get (nth 0 (elfeed-meta entry2 :authors)) :name) 93 | "@author2")) 94 | (should (equal 95 | (elfeed-entry-tags entry1) 96 | '(Emacs tag1))) 97 | (should (equal 98 | (elfeed-entry-tags entry2) 99 | '(publish Emacs star tag1 unread))) 100 | (should (string= 101 | (cdr (elfeed-entry-id entry1)) 102 | "SHA1:aeb92f1daca1aadd1e58ca9b8c820fab48703ef2")) 103 | (should (string= 104 | (cdr (elfeed-entry-id entry2)) 105 | "urn:sha1:0b36197f75b63a54cf6152972f18f704479380d3")))))))))) 106 | 107 | (ert-deftest elfeed-protocol-ttrss-parse-no-feed-id-entries () 108 | (with-elfeed-test 109 | (with-fixture elfeed-protocol-ttrss-fixture-feeds 110 | (let* ((proto-url "ttrss+https://user:pass@myhost.com") 111 | (host-url (elfeed-protocol-url proto-url)) 112 | (proto-id (elfeed-protocol-ttrss-id host-url)) 113 | (elfeed-protocol-feeds `((,proto-url 114 | :autotags 115 | '(("http://tt-rss.org/forum/rss.php" tag1))))) 116 | (elfeed-protocol-ttrss-feeds (elfeed-protocol-ttrss--parse-result 117 | (elfeed-protocol-ttrss--parse-feeds 118 | host-url content)))) 119 | 120 | (with-fixture elfeed-protocol-ttrss-fixture-no-feed-id-entries 121 | (let* ((entries (elfeed-protocol-ttrss--parse-result 122 | (elfeed-protocol-ttrss--parse-entries 123 | host-url content))) 124 | (entry1 (elt entries 0))) 125 | (should (equal (length entries) 1)) 126 | (should (elfeed-protocol-ttrss-entry-p entry1)) 127 | (should (string= 128 | (elfeed-entry-title entry1) 129 | "Pictures not shown in some feeds with figure block")) 130 | (should (equal 131 | (elfeed-entry-tags entry1) 132 | '(star tag1 unread))))))))) 133 | -------------------------------------------------------------------------------- /test/fixtures/fever/categories.json: -------------------------------------------------------------------------------- 1 | { 2 | "api_version": 3, 3 | "auth": 1, 4 | "last_refreshed_on_time": 1695560965, 5 | "groups": [ 6 | { 7 | "id": 1, 8 | "title": "Category 1" 9 | } 10 | ], 11 | "feeds_groups": [ 12 | { 13 | "group_id": 1, 14 | "feed_ids": "1,4,154" 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /test/fixtures/fever/entries.json: -------------------------------------------------------------------------------- 1 | { 2 | "api_version": 3, 3 | "auth": 1, 4 | "total_items": 30024, 5 | "items": [ 6 | { 7 | "id": 1, 8 | "feed_id": 1, 9 | "title": "Pictures not shown in some feeds with figure block", 10 | "author": "author1", 11 | "html": "content1", 12 | "url": "http://discourse.tt-rss.org/t/pictures-not-shown-in-some-feeds-with-figure-block/79/14", 13 | "is_saved": 0, 14 | "is_read": 1, 15 | "created_on_time": 1576367760 16 | }, 17 | { 18 | "id": 2, 19 | "feed_id": 1, 20 | "title": "PDO is coming, here's what you need to know", 21 | "author": "author2", 22 | "html": "content2", 23 | "url": "http:http://discourse.tt-rss.org/t/pdo-is-coming-heres-what-you-need-to-know/689/6", 24 | "is_saved": 1, 25 | "is_read": 0, 26 | "created_on_time": 1576367760 27 | }, 28 | { 29 | "id": "3", 30 | "feed_id": 2, 31 | "title": "FreshRSS 1.13.1", 32 | "author": "author3", 33 | "html": "content3", 34 | "url": "https://github.com/FreshRSS/FreshRSS/releases/tag/1.13.1", 35 | "is_saved": 0, 36 | "is_read": 1, 37 | "created_on_time": 1548515100 38 | }, 39 | { 40 | "id": 4, 41 | "feed_id": "2", 42 | "title": "Cloned FreshRSS 1.13.1", 43 | "author": "author4", 44 | "html": "content4", 45 | "url": "https://github.com/FreshRSS/FreshRSS/releases/tag/1.13.1", 46 | "is_saved": 0, 47 | "is_read": 1, 48 | "created_on_time": 1548515100 49 | } 50 | ], 51 | "last_refreshed_on_time": "1581326728" 52 | } 53 | -------------------------------------------------------------------------------- /test/fixtures/fever/feeds.json: -------------------------------------------------------------------------------- 1 | { 2 | "api_version": 3, 3 | "auth": 1, 4 | "feeds": [ 5 | { 6 | "id": 1, 7 | "favicon_id": 1, 8 | "title": "Tiny Tiny RSS:\nForum", 9 | "url": "http://tt-rss.org/forum/rss.php", 10 | "site_url": "http://tt-rss.org", 11 | "is_spark": 0, 12 | "last_updated_on_time": 1581325594 13 | }, 14 | { 15 | "id": 2, 16 | "favicon_id": 1, 17 | "title": "FreshRSS releases", 18 | "url": "https://github.com/FreshRSS/FreshRSS/releases.atom", 19 | "site_url": "https://github.com/FreshRSS/FreshRSS/", 20 | "is_spark": 0, 21 | "last_updated_on_time": 1581325594 22 | } 23 | ], 24 | "feeds_groups": [ 25 | { 26 | "group_id": 1, 27 | "feed_ids": "1,4,154" 28 | } 29 | ], 30 | "last_refreshed_on_time": "1581326855" 31 | } 32 | -------------------------------------------------------------------------------- /test/fixtures/newsblur/entries.json: -------------------------------------------------------------------------------- 1 | { 2 | "code": 1, 3 | "authenticated": true, 4 | "hidden_stories_removed": 0, 5 | "elapsed_time": 0.18, 6 | "user_search": null, 7 | "stories": [ 8 | { 9 | "friend_shares": [], 10 | "story_authors": "pearphp", 11 | "intelligence": { 12 | "feed": 0, 13 | "tags": 0, 14 | "author": 0, 15 | "title": 1 16 | }, 17 | "story_permalink": "https://news.ycombinator.com/item?id=15889939", 18 | "reply_count": 0, 19 | "comment_user_ids": [], 20 | "story_timestamp": "1512880499", 21 | "share_user_ids": [], 22 | "story_hash": "6188470:5a2628", 23 | "id": "https://news.ycombinator.com/item?id=15889939", 24 | "comment_count": null, 25 | "score": 1, 26 | "story_tags": [], 27 | "share_count": null, 28 | "friend_comments": [], 29 | "story_date": "2017-12-10 04:34:59", 30 | "short_parsed_date": "Yesterday, 11:34pm", 31 | "guid_hash": "5a2628", 32 | "image_urls": [], 33 | "story_feed_id": 569, 34 | "long_parsed_date": "Yesterday, December 9th 11:34pm", 35 | "public_comments": [], 36 | "read_status": 1, 37 | "has_modifications": false, 38 | "story_title": "Ask HN: What software/service helps you be an effective remote developer?", 39 | "story_content": "

Article URL: https://news.ycombinator.com/item?id=15889939

Comments URL: https://news.ycombinator.com/item?id=15889939

Points: 54

# Comments: 29

" 40 | }, 41 | { 42 | "friend_shares": [], 43 | "story_authors": "Andrew Liptak", 44 | "intelligence": { 45 | "feed": 0, 46 | "tags": 0, 47 | "author": 0, 48 | "title": 0 49 | }, 50 | "story_permalink": "https://www.theverge.com/2017/12/9/16756896/jessica-jones-season-2-teaser-trailer-watch", 51 | "reply_count": 0, 52 | "comment_user_ids": [], 53 | "story_timestamp": "1512858665", 54 | "share_user_ids": [], 55 | "story_hash": "576138:52eed5", 56 | "id": "https://www.theverge.com/2017/12/9/16756896/jessica-jones-season-2-teaser-trailer-watch", 57 | "comment_count": null, 58 | "score": 0, 59 | "story_tags": [ 60 | "fundings & exits", 61 | "hyperloop" 62 | ], 63 | "share_count": null, 64 | "friend_comments": [], 65 | "story_date": "2017-12-09 22:31:05", 66 | "short_parsed_date": "Yesterday, 5:31pm", 67 | "guid_hash": "52eed5", 68 | "image_urls": [ 69 | "https://cdn.vox-cdn.com/thumbor/KReBajkoWVvP5vYpwxqXWi8cD0w=/270x0:1920x864/fit-in/1200x630/cdn.vox-cdn.com/uploads/chorus_asset/file/9841323/Screen_Shot_2017_12_09_at_5.18.58_PM.png" 70 | ], 71 | "story_feed_id": 1186180, 72 | "long_parsed_date": "Yesterday, December 9th 5:31pm", 73 | "public_comments": [], 74 | "read_status": 0, 75 | "has_modifications": false, 76 | "story_title": "Jessica Jones’ second season gets its first teaser", 77 | "story_content": "\\\"\\\"\\n\\n\\n\\n

When we last saw Jessica Jones in Netflix’s The Defenders, she escaped from the destruction of Midland Circle along with Luke Cage and Danny Rand, who all look to move on with their lives after stopping The Hand. Netflix debuted the first trailer for the next season of Marvel’s Jessica Jones, showing that while Jones is trying to move on, her past is catching up to her.

\\n

In the teaser, we see that Jones is back to working as a private investigator, musing that people have their secrets, or at least someone else’s. It seems that there’s still some surprises in her past: her friend Trish telling her that knowing what was done to her might be helpful. Jones isn’t sold on the idea, asking “what if facing it makes me worse?” Along the way,...

\\n

\\n Continue reading…\\n

", 78 | "starred": true 79 | } 80 | ], 81 | "result": "ok", 82 | "message": null, 83 | "classifiers": { 84 | "576138": { 85 | "authors": {}, 86 | "feeds": {}, 87 | "titles": { 88 | "iPhone": 1 89 | }, 90 | "tags": {} 91 | }, 92 | "6188470": { 93 | "authors": {}, 94 | "feeds": {}, 95 | "titles": { 96 | "NYTimes": 1, 97 | "Python": 1, 98 | "Deep Learning": 1, 99 | "JavaScript": 1, 100 | "Facebook": -1, 101 | "Ask HN": 1 102 | }, 103 | "tags": {} 104 | } 105 | }, 106 | "user_profiles": [] 107 | } 108 | -------------------------------------------------------------------------------- /test/fixtures/newsblur/feeds.json: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "Writers": [ 5 | 76, 6 | 38, 7 | 569, 8 | 183139, 9 | 5708255, 10 | 21309 11 | ] 12 | }, 13 | { 14 | "Blogs": [ 15 | 6227976, 16 | 6227690, 17 | 3581, 18 | 5994357, 19 | 1186180, 20 | 5636682, 21 | 526, 22 | 5261603, 23 | { 24 | "Photoblogs": [ 25 | 50, 26 | 551953, 27 | 34, 28 | 776101, 29 | 3556, 30 | 1480028, 31 | 1095, 32 | 588075, 33 | 5984253, 34 | 5752038, 35 | 1627 36 | ] 37 | }, 38 | 6605581 39 | ] 40 | }, 41 | 8032018 42 | ], 43 | "saved_searches": [], 44 | "user_id": 39040, 45 | "social_profile": { 46 | "website": "", 47 | "following_user_ids": [ 48 | 32048, 49 | 13, 50 | 33405, 51 | 26578, 52 | 219352 53 | ], 54 | "following_count": 5, 55 | "shared_stories_count": 0, 56 | "private": true, 57 | "large_photo_url": "https://www.gravatar.com/avatar/e3c7a29b7538122f0ee20f8e9cf05f42", 58 | "id": "social:39040", 59 | "feed_address": "http://www.newsblur.com/social/rss/39040/homepage", 60 | "user_id": 39040, 61 | "feed_link": "http://homepage.newsblur.com/", 62 | "follower_user_ids": [ 63 | 33143, 64 | 33727, 65 | 39285, 66 | 35059 67 | ], 68 | "location": "", 69 | "popular_publishers": [], 70 | "follower_count": 4, 71 | "username": "homepage", 72 | "bio": "", 73 | "average_stories_per_month": 0, 74 | "feed_title": "homepage's blurblog", 75 | "photo_service": "gravatar", 76 | "stories_last_month": 0, 77 | "photo_url": "https://www.gravatar.com/avatar/e3c7a29b7538122f0ee20f8e9cf05f42", 78 | "num_subscribers": 4, 79 | "protected": true 80 | }, 81 | "starred_counts": [ 82 | { 83 | "count": 0, 84 | "feed_address": "http://www.newsblur.com/reader/starred_rss/39040/75ddb05c6a00/", 85 | "tag": "", 86 | "feed_id": null 87 | } 88 | ], 89 | "starred_count": 0, 90 | "is_staff": false, 91 | "result": "ok", 92 | "authenticated": true, 93 | "feeds": { 94 | "1186180": { 95 | "subs": 14627, 96 | "favicon_url": "https://s3.amazonaws.com/icons.newsblur.com/1186180.png", 97 | "is_push": false, 98 | "feed_opens": 183034, 99 | "id": 1186180, 100 | "s3_icon": true, 101 | "feed_link": "http://bestof.metafilter.com/", 102 | "updated_seconds_ago": 1055, 103 | "favicon_fetching": false, 104 | "ng": 0, 105 | "favicon_border": "004c72", 106 | "last_story_date": "2017-12-09 17:01:18", 107 | "nt": 1, 108 | "not_yet_fetched": false, 109 | "updated": "17 minutes", 110 | "average_stories_per_month": 10, 111 | "ps": 0, 112 | "feed_address": "http://feeds.feedburner.com/BestOfMetafilter", 113 | "feed_title": "Best of MetaFilter", 114 | "favicon_fade": "2489bb", 115 | "is_newsletter": false, 116 | "last_story_seconds_ago": 51343, 117 | "favicon_color": "016698", 118 | "stories_last_month": 19, 119 | "active": true, 120 | "fetched_once": true, 121 | "favicon_text_color": "white", 122 | "subscribed": true, 123 | "num_subscribers": 14627, 124 | "s3_page": false, 125 | "min_to_decay": 22, 126 | "search_indexed": true 127 | }, 128 | "569": { 129 | "subs": 16058, 130 | "favicon_url": "https://s3.amazonaws.com/icons.newsblur.com/569.png", 131 | "is_push": false, 132 | "feed_opens": 40418, 133 | "id": 569, 134 | "s3_icon": true, 135 | "feed_link": "http://anildash.com/", 136 | "updated_seconds_ago": 965, 137 | "favicon_fetching": false, 138 | "ng": 0, 139 | "favicon_border": "818180", 140 | "last_story_date": "2017-09-11 13:07:05", 141 | "nt": 0, 142 | "not_yet_fetched": false, 143 | "updated": "16 minutes", 144 | "average_stories_per_month": 3, 145 | "ps": 0, 146 | "feed_address": "http://feeds.dashes.com/AnilDash", 147 | "feed_title": "Anil\nDash", 148 | "favicon_fade": "cfcfce", 149 | "is_newsletter": false, 150 | "last_story_seconds_ago": 7754996, 151 | "favicon_color": "acacab", 152 | "stories_last_month": 0, 153 | "active": true, 154 | "fetched_once": true, 155 | "favicon_text_color": "white", 156 | "subscribed": true, 157 | "num_subscribers": 16058, 158 | "s3_page": false, 159 | "min_to_decay": 720, 160 | "search_indexed": true 161 | } 162 | }, 163 | "social_services": { 164 | "facebook": { 165 | "syncing": false, 166 | "facebook_picture_url": null, 167 | "facebook_uid": null 168 | }, 169 | "twitter": { 170 | "twitter_username": null, 171 | "syncing": false, 172 | "twitter_picture_url": null, 173 | "twitter_uid": null 174 | }, 175 | "gravatar": { 176 | "gravatar_picture_url": "https://www.gravatar.com/avatar/e3c7a29b7538122f0ee20f8e9cf05f42" 177 | }, 178 | "appdotnet": { 179 | "syncing": false, 180 | "appdotnet_uid": null, 181 | "appdotnet_picture_url": null 182 | }, 183 | "upload": { 184 | "upload_picture_url": null 185 | } 186 | }, 187 | "categories": null, 188 | "social_feeds": [ 189 | { 190 | "username": "popular", 191 | "ps": 0, 192 | "user_id": 32048, 193 | "subscription_user_id": 32048, 194 | "feed_link": "http://popular.newsblur.com/", 195 | "feed_address": "http://www.newsblur.com/social/rss/32048/popular", 196 | "feed_opens": 59743, 197 | "num_subscribers": 42590, 198 | "shared_stories_count": 2163, 199 | "private": false, 200 | "feed_title": "The People Have Spoken", 201 | "protected": false, 202 | "location": "", 203 | "photo_url": "https://s3.amazonaws.com/avatars.newsblur.com/avatars/32048/thumbnail_profile_1358188630.jpg", 204 | "large_photo_url": "https://s3.amazonaws.com/avatars.newsblur.com/avatars/32048/large_profile_1358188630.jpg", 205 | "is_trained": false, 206 | "ng": 0, 207 | "nt": 0, 208 | "id": "social:32048", 209 | "page_url": "/social/page/32048/popular" 210 | } 211 | ] 212 | } 213 | -------------------------------------------------------------------------------- /test/fixtures/owncloud/categories.json: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "id": 1, 5 | "name": "Category 1" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /test/fixtures/owncloud/entries.json: -------------------------------------------------------------------------------- 1 | { 2 | "items": [ 3 | { 4 | "id": 1, 5 | "guid": "646062e8942103b24ae2470b552577dd", 6 | "guidHash": "646062e8942103b24ae2470b552577dd", 7 | "url": "http://www.example.com/test.html?from=rss", 8 | "title": "Entry 1", 9 | "author": "author1 ", 10 | "pubDate": 1493260874, 11 | "body": "

body 1...

", 12 | "enclosureMime": null, 13 | "enclosureLink": null, 14 | "feedId": 1, 15 | "unread": false, 16 | "starred": false, 17 | "lastModified": 1493260874, 18 | "rtl": false, 19 | "fingerprint": "d20ec9d7c728c6486f418e3d725b03ad", 20 | "contentHash": "3e0d73ae064930f5f0c0eebb3258c100" 21 | }, 22 | { 23 | "id": 2, 24 | "guid": "06b3c14d9433ea9bbdea131bd37168d8", 25 | "guidHash": "06b3c14d9433ea9bbdea131bd37168d8", 26 | "url": "http://www.example.com/test2.html?from=rss", 27 | "title": "Entry 2", 28 | "author": "author2 ", 29 | "pubDate": 1493260874, 30 | "body": "

body 2...

", 31 | "enclosureMime": "video/webm", 32 | "enclosureLink": "http://www.example/test.webm", 33 | "feedId": 2, 34 | "unread": true, 35 | "starred": true, 36 | "lastModified": 1493260874, 37 | "rtl": false, 38 | "fingerprint": "6fb19b56a1c30f8e952af57b809d3dec", 39 | "contentHash": "61206dd01bba2282c261215bfc24c6e5" 40 | } 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /test/fixtures/owncloud/feeds.json: -------------------------------------------------------------------------------- 1 | { 2 | "starredCount": 1, 3 | "feeds": [ 4 | { 5 | "id": 1, 6 | "url": "http://www.example.com/feed/", 7 | "title": "Feed 1", 8 | "faviconLink": "http://www.example.com/favicon.ico", 9 | "added": 1492783825, 10 | "folderId": 1, 11 | "unreadCount": 2, 12 | "ordering": 0, 13 | "link": "http://www.example.com/", 14 | "pinned": false, 15 | "updateErrorCount": 0, 16 | "lastUpdateError": null 17 | }, 18 | { 19 | "id": 2, 20 | "url": "http://www.example2.com/rss.jsp", 21 | "title": "Feed\n2", 22 | "faviconLink": "", 23 | "added": 1492784045, 24 | "folderId": 12, 25 | "unreadCount": 0, 26 | "ordering": 0, 27 | "link": "http://www.example2.com/", 28 | "pinned": false, 29 | "updateErrorCount": 0, 30 | "lastUpdateError": "" 31 | } 32 | ], 33 | "newestItemId": 2 34 | } 35 | -------------------------------------------------------------------------------- /test/fixtures/ttrss/categories.json: -------------------------------------------------------------------------------- 1 | { 2 | "seq": 0, 3 | "status": 0, 4 | "content": [ 5 | { 6 | "id": 1, 7 | "title": "News", 8 | "unread": 0, 9 | "order_id": 0 10 | }, 11 | { 12 | "id": 2, 13 | "title": "Emacs", 14 | "unread": 0, 15 | "order_id": 0 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/fixtures/ttrss/entries-no-feed-id.json: -------------------------------------------------------------------------------- 1 | { 2 | "seq": 0, 3 | "status": 0, 4 | "content": [ 5 | { 6 | "id": 1, 7 | "unread": true, 8 | "marked": true, 9 | "published": false, 10 | "updated": 1494158580, 11 | "is_updated": false, 12 | "title": "Pictures not shown in some feeds with figure block", 13 | "link": "http://discourse.tt-rss.org/t/pictures-not-shown-in-some-feeds-with-figure-block/79/14", 14 | "feed_id": null, 15 | "tags": [ 16 | "" 17 | ], 18 | "attachments": [], 19 | "content": "content1", 20 | "labels": [], 21 | "feed_title": "Tiny Tiny RSS:\nForum", 22 | "comments_count": 0, 23 | "comments_link": "", 24 | "always_display_attachments": false, 25 | "author": "@fox", 26 | "score": 0, 27 | "note": null, 28 | "lang": "" 29 | }, 30 | { 31 | "id": 2, 32 | "unread": true, 33 | "marked": true, 34 | "published": true, 35 | "updated": 1512246430, 36 | "is_updated": false, 37 | "title": "PDO is coming, here's what you need to know", 38 | "link": "http://discourse.tt-rss.org/t/pdo-is-coming-heres-what-you-need-to-know/689/6", 39 | "feed_id": null, 40 | "tags": [ 41 | "ttrss_tag1", 42 | "ttrss_tag2" 43 | ], 44 | "content": "content2", 45 | "labels": [], 46 | "feed\_title": "invalid feed title", 47 | "comments\_count": 0, 48 | "comments\_link": "", 49 | "always\_display_attachments": false, 50 | "author": "@fox", 51 | "score": 0, 52 | "note": null, 53 | "lang": "" 54 | } 55 | ] 56 | } 57 | -------------------------------------------------------------------------------- /test/fixtures/ttrss/entries.json: -------------------------------------------------------------------------------- 1 | { 2 | "seq": 0, 3 | "status": 0, 4 | "content": [ 5 | { 6 | "id": 1, 7 | "guid": "SHA1:aeb92f1daca1aadd1e58ca9b8c820fab48703ef2", 8 | "unread": false, 9 | "marked": false, 10 | "published": false, 11 | "updated": 1494158580, 12 | "is_updated": false, 13 | "title": "Pictures not shown in some feeds with figure block", 14 | "link": "http://discourse.tt-rss.org/t/pictures-not-shown-in-some-feeds-with-figure-block/79/14", 15 | "feed_id": "1", 16 | "tags": [ 17 | "" 18 | ], 19 | "attachments": [], 20 | "content": "content1", 21 | "labels": [], 22 | "feed_title": "Tiny Tiny RSS: Forum", 23 | "comments_count": 0, 24 | "comments_link": "", 25 | "always_display_attachments": false, 26 | "author": "@author1", 27 | "score": 0, 28 | "note": null, 29 | "lang": "" 30 | }, 31 | { 32 | "id": 2, 33 | "unread": true, 34 | "marked": true, 35 | "published": true, 36 | "updated": 1512246430, 37 | "is_updated": false, 38 | "title": "PDO is coming, here's what you need to know", 39 | "link": "http://discourse.tt-rss.org/t/pdo-is-coming-heres-what-you-need-to-know/689/6", 40 | "feed_id": 1, 41 | "tags": [ 42 | "ttrss_tag1", 43 | "ttrss_tag2" 44 | ], 45 | "content": "content2", 46 | "labels": [], 47 | "feed\_title": "Tiny Tiny RSS: Forum", 48 | "comments\_count": 0, 49 | "comments\_link": "", 50 | "always\_display_attachments": false, 51 | "author": "@author2", 52 | "score": 0, 53 | "note": null, 54 | "lang": "" 55 | } 56 | ] 57 | } 58 | -------------------------------------------------------------------------------- /test/fixtures/ttrss/feeds.json: -------------------------------------------------------------------------------- 1 | { 2 | "seq":0, 3 | "status":0, 4 | "content":[ 5 | { 6 | "feed_url":"http://tt-rss.org/forum/rss.php", 7 | "title":"Tiny Tiny RSS:\nForum", 8 | "id":1, 9 | "unread":46, 10 | "has_icon":true, 11 | "cat_id":2, 12 | "last_updated":1494163883, 13 | "order_id":0 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /test/test-checkdoc.el: -------------------------------------------------------------------------------- 1 | (add-to-list 'load-path default-directory) 2 | 3 | (defvar elfeed-protocol-sources (file-expand-wildcards "*.el")) 4 | 5 | ;; test byte-comple 6 | ;; (mapc #'byte-compile-file `(,cdnjs-el)) 7 | 8 | ;; test checkdoc 9 | (dolist (source elfeed-protocol-sources) 10 | (with-current-buffer (find-file-noselect source) 11 | (let ((checkdoc-diagnostic-buffer "*warn*")) 12 | (checkdoc-current-buffer t)))) 13 | -------------------------------------------------------------------------------- /test/test-helper.el: -------------------------------------------------------------------------------- 1 | (load-file "elfeed-protocol-common.el") 2 | (load-file "elfeed-protocol-fever.el") 3 | (load-file "elfeed-protocol-newsblur.el") 4 | (load-file "elfeed-protocol-owncloud.el") 5 | (load-file "elfeed-protocol-ttrss.el") 6 | (load-file "elfeed-protocol.el") 7 | 8 | (elfeed-protocol-enable) 9 | 10 | ;;; copy from elfeed/tests/elfeed-db-tests.el 11 | (defmacro with-elfeed-test (&rest body) 12 | "Run BODY with a fresh, empty database that will be destroyed on exit." 13 | (declare (indent defun)) 14 | `(let* ((elfeed-db nil) 15 | (elfeed-db-feeds nil) 16 | (elfeed-db-entries nil) 17 | (elfeed-db-index nil) 18 | (elfeed-feeds nil) 19 | (elfeed-protocol-feeds nil) 20 | (temp-dir (make-temp-file "elfeed-test-" t)) 21 | (elfeed-db-directory temp-dir) 22 | (elfeed-new-entry-hook nil) 23 | (elfeed-db-update-hook nil) 24 | (elfeed-log-level 'debug) 25 | (elfeed-initial-tags '(unread)) 26 | (elfeed-protocol-fever-categories (make-hash-table :test 'equal)) 27 | (elfeed-protocol-fever-feeds (make-hash-table :test 'equal)) 28 | (elfeed-protocol-newsblur-categories (make-hash-table :test 'equal)) 29 | (elfeed-protocol-newsblur-feeds (make-hash-table :test 'equal)) 30 | (elfeed-protocol-owncloud-categories (make-hash-table :test 'equal)) 31 | (elfeed-protocol-owncloud-feeds (make-hash-table :test 'equal)) 32 | (elfeed-protocol-ttrss-categories (make-hash-table :test 'equal)) 33 | (elfeed-protocol-ttrss-feeds (make-hash-table :test 'equal))) 34 | (when (get-buffer elfeed-log-buffer-name) 35 | (kill-buffer elfeed-log-buffer-name)) 36 | (unwind-protect 37 | (progn ,@body) 38 | (delete-directory temp-dir :recursive)))) 39 | 40 | (defmacro with-fixture (fixture-path &rest body) 41 | "Run BODY with the contents of the file specified by 42 | FIXTURE-PATH inserted into a temporary buffer." 43 | (declare (indent defun)) 44 | `(with-temp-buffer 45 | (insert-file-contents ,fixture-path) 46 | (goto-char (point-min)) 47 | ,@body)) 48 | 49 | (defun dump-elfeed-log () 50 | "Print *elfeed-log* buffer content." 51 | (with-current-buffer elfeed-log-buffer-name (message "%s" (buffer-string)))) 52 | --------------------------------------------------------------------------------